1. 程式人生 > >react native中引入antd-mobile

react native中引入antd-mobile

1.安裝antd-mobilebabel-plugin-import

yarn add antd-mobile react-dom
yarn add --dev babel-plugin-import

2.編輯 .babelrc

{"plugins": [["import", { "libraryName": "antd-mobile" }]]}

3.使用

import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { Button } from 'antd-mobile'
; class HelloWorldApp extends Component { render() { return <Button>Start</Button>; } } AppRegistry.registerComponent('HelloWorldApp', () => HelloWorldApp);