让前端飞Web前端之路

Antd V4 使用iconType创建Icon,可动态设置ic

2020-03-27  本文已影响0人  六二小盆友
image.png

后台数据库存的icon type是antd v4的icon

image.png

前端页面应该如何使用显示icon呢

解决办法如下

import React from "react";
import  * as Icon from '@ant-design/icons';

var iconType = 'MessageOutlined';

export default function App() {
  return (
    <div > 
    {
      React.createElement(
        Icon[iconType],
        {
          style:{ fontSize: '16px', color: '#08c' }
        }
      )
    }
    </div>
  );
}
上一篇 下一篇

猜你喜欢

热点阅读