react-native alias别名设置

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: "@/"
        }
    ]
  ]
};

猜你喜欢

转载自blog.csdn.net/KK_vicent/article/details/129703203