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

2,927 阅读1分钟

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

前端页面根据后台返回的icon-type的值,动态显示 Icon

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

var iconType = 'FastBackwardOutlined';

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