antd v4 如何使用后台返回的icon type使用icon?

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

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

阅读 4.3k
1 个回答

可以这么写

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>
  );
}
推荐问题