記錄一下搭建
1.安裝
$ npm install -g create-react-app cordova yarn
2.新建cordova
項(xiàng)目
$ cordova create testdev
可以看到項(xiàng)目結(jié)構(gòu)
3.在cordova
項(xiàng)目根目錄創(chuàng)建react
項(xiàng)目
$ create-react-app src
對(duì) 览效,就叫src
,舒服
然后再安裝 ant.design mobile
$ yarn add antd-mobile
$ yarn add babel-plugin-import react-app-rewired --dev
4.進(jìn)入src
目錄控淡,修改package.json
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build && ((robocopy .\\build ..\\www /MIR) & exit 0)",,
"test": "react-app-rewired test --env=jsdom",
}
5.再src
目錄下弥虐,新建config-overrides.js
const { injectBabelPlugin } = require('react-app-rewired');
module.exports = function override(config, env) {
config = injectBabelPlugin(['import', { libraryName: 'antd-mobile', style: 'css' }], config);
return config;
};
6.開發(fā)時(shí),使用
$ yarn start
7.手機(jī)調(diào)試使用
在src
目錄下
$ yarn build
在cordova項(xiàng)目根目錄下
卡在gradle的話晕换,網(wǎng)速問題
$ cordova platform add android
$ cordova run android