官方版本https://weex.apache.org/zh/guide/develop/create-a-new-app.html#初始化
感觉讲的还是比较清楚的。
这里总结一下集成遇到的问题。
创建一个新项目流程
cd 到目录
weex create my-project
cd my-project
npm install
有个警告(babel-loader@6.4.1 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none is installed. You must install peer dependencies yourself.)可忽略
npm start
如果报这个错误(npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! testweex1@1.0.0 serve: `webpack-dev-server --env.NODE_ENV=development --progress` npm ERR! Exit status 1)
端口号被占用、重启终端即可。
网上查了关闭终端方法(https://blog.youkuaiyun.com/mingzznet/article/details/38345875)
先lsof -i:8080查找到端口号
lsof -i:8080
然后kill -9 15521
kill -9 15521
实际上我关闭了终端重启后就可以了。
打包成web
执行npm run pack:web就会有一个release文件夹,里面的html打开即可。
npm run pack:web
记录下运行完给的执行说明
包括其他平台,ios,安卓,web
Inside that directory, you can run several commands:
npm start
Starts the development server for you to preview your weex page on browser
You can also scan the QR code using weex playground to preview weex page on native
npm run dev
Open the code compilation task in watch mode
npm run ios
(Mac only, requires Xcode)
Starts the development server and loads your app in an iOS simulator
npm run android
(Requires Android build tools)
Starts the development server and loads your app on a connected Android device or emulator
npm run pack:ios
(Mac only, requires Xcode)
Packaging ios project into ipa package
npm run pack:android
(Requires Android build tools)
Packaging android project into apk package
npm run pack:web
Packaging html5 project into `web/build` folder
npm run test
Starts the test runner
To get started:
cd my-project
npm start