npm install babel-plugin-root-import --save-dev
npm install babel-plugin-import --save-dev
npm install --dev babel-eslint
.eslintrc.js中添加
module.exports = {
root: true,
extends: '@react-native-community',
parse: 'babel-eslint',
};
创建.babel.config.js
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
['import', {libraryName: '@ant-design/react-native'}],
[
"babel-plugin-root-import",
{
rootPathSuffix: "./src",
rootPathPrefix: "@/"
}
]
]
};
文章讲述了如何在ReactNative项目中安装并配置`babel-plugin-root-import`和`babel-plugin-import`插件,以及`babel-eslint`解析器。通过修改`.eslintrc.js`文件,使用`@react-native-community`的扩展,并在`.babel.config.js`中设定`rootPathSuffix`和`rootPathPrefix`,以便优化`@ant-design/react-native`库的导入方式。
2168

被折叠的 条评论
为什么被折叠?



