1

我需要 从create-react-native-app生成的项目中添加{"plugins": [["import", { "libraryName": "antd-mobile" }]]},以使ant-design-mobile在 react native 中工作。.babelrc

我已经使用create-react-native-app开始了一个新项目。将 .babelrc 更改为:

 {
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": [
        "transform-react-jsx-source",
      ]
    }
  },
  "plugins": [
    ["import", { "libraryName": "antd-mobile" }]
  ]
}

班级:

import { Button } from 'antd-mobile';

export class Screen extends React.Component<any,{}>{
   render(){
     return(
            <View>
                <Button>Something</Button>
            </View>
        )
   }
}

但是,我仍然在开始时收到此错误:

Note: must use https://github.com/ant-design/babel-plugin-import .
For more information, please see https://github.com/ant-design/ant-design-mobile/issues/602

谁能指出我的解决方案?

4

1 回答 1

0

你可以看看官方的 react-native 应用演示:https ://github.com/ant-design/antd-mobile-samples/tree/master/react-native

于 2017-05-17T12:42:29.767 回答