ant-design-mobile是否与create-react-native-app兼容?

时间:2017-05-17 05:37:10

标签: javascript react-native antd create-react-native-app

我需要从 create-react-native-app 生成的项目中将{"plugins": [["import", { "libraryName": "antd-mobile" }]]}添加到.babelrc,以使ant-design-mobile在本机中生效。< / p>

我已经使用 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

有人能指出我的解决方案吗?

1 个答案:

答案 0 :(得分:0)

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