javascript - 使用antdesign的babel-plugin-import,怎么配置?
問(wèn)題描述
1、這是文件夾中的文件
2、package.json 中的配置
3、運(yùn)用npm install 將加載了node_modules中的文件
4、運(yùn)行的入口代碼(npm run dev 啟動(dòng)服務(wù))
5、瀏覽器報(bào)錯(cuò)信息(訪問(wèn):localhost:8000/index.html)
index.html
問(wèn)題:1、Note: must use https://github.com/ant-design... .For more information, please see https://github.com/ant-design... 這個(gè)報(bào)錯(cuò)怎么解決呢?
2、arning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of WingBlankExample.這樣子的報(bào)錯(cuò),是什么原因呢?應(yīng)該怎么來(lái)處理?請(qǐng)大神給出解答,感激不盡。
問(wèn)題解答
回答1:1、配置 babelrc 或者在 webpack 中添加 babel-loader
// .babelrc or babel-loader option{ 'plugins': [ ['import', { libraryName: 'antd', style: 'css' }] // `style: true` 會(huì)加載 less 文件 ]}
2、組件引用錯(cuò)誤:使用函數(shù)定義的組件不要加< />
ReactDom.render(WingBlankExample, document.body);
