美文网首页
create-react-app 中使用antd 时组件未被渲染

create-react-app 中使用antd 时组件未被渲染

作者: 天涯笑笑生 | 来源:发表于2018-07-13 11:15 被阅读0次

问题描述:使用create-react-app 脚手架创建的react + antd 应用,antd 组件没有被antd底层的样式文件渲染(css或less,js文件未被执行)

解决方案:

npm install --save-dev babel-plugin-import react-app-rewired

根目录下创建config-overrides.js

const { injectBabelPlugin } = require('react-app-rewired');
module.exports = function override(config, env) {

    // do stuff with the webpack config...
    config = injectBabelPlugin(['import', { libraryName: 'antd-mobile', style: 'css' }], config);

    return config;
}

注:当然,使用react-app-rewired,package也要做相应的修改

相关文章

网友评论

      本文标题:create-react-app 中使用antd 时组件未被渲染

      本文链接:https://www.haomeiwen.com/subject/fxhjpftx.html