前言
环境搭建
1.
2.
3.
4.
brew install nodenpm install -g weex-toolkitnpm install -g weexpacknpm install -g weextools
脚手架常用命令
weextools:Commands: create [name] initialize a standard weex project platform [command] command for add or remove a platform project run [platform] run weex app on the specific platform build [platform] build weex app generator package(apk or ipa) install [platform] install weex app to mobile plugin [command] command for add,create,login,publish weex plugins weexplugin [command] create a project that is a manager of plugin help [cmd] display help for [cmd]
项目初始化
weex init demoweexpack create demo1weextools create demo2
项目
官方demo:
components ——vue组件views ——视图store ——Vuexmixins——扩展filters——vue.js 的filterApp.vue 主UI界面entry.js 入口程序router.js ——vue-router
2. ucar-weex
WeexProject ├── dist 编译(js文件)目录 | └── views/index.js | └── package | └── ucar-weex_1_20170910101838.so | └── ucar-weex_1_20170910101838.json ├── hooks │ └── README.md ├── node_modules node依赖包 ├── package.json node配置文件 ├── platforms // 平台模版目录 │ └── android │ └── ios ├── plugins // 插件下载目录 │ └── README.md ├── src // 业务代码(we文件)目录 │ └── views │ └── index.vue │ └── pageA.vue │ └── assets │ └── image/icon_back.png │ └── font/icon_font.ttf ├── tools │ └── android │ └── ios │ └── packzip.js │ └── webpack.config.plugin.js └── webpack.config.js //webpack 编译脚本
2.
3. weex集成ucar-weex
npm install ucar-weex --save
- ucar-weex 基础api
项目调试
npm run devweex debug
打包发布
1. 第一步
npm run packzip
- ucar-weex_1_20170910101838.json
- ucar-weex_1_20170910101838.so
2. 第二步
npm run copy:android
- .json |.so => android/assets
3. 第三步
- .json |.so => 发布到服务器
4. 第四步
UWXResManager.getInstance().addWXResFromAssert(this, FileUtils.getWXPackageFileName(this,"weex"));// UWXResManager.getInstance().setServerUrl(""); UWXResManager.getInstance().checkUpdate(new UWXResManager.CheckUpdateCallback() { @Override public void callback(int code, String msg, WXPackageInfo info) { Toast.makeText(WXApplication.this, msg, Toast.LENGTH_LONG).show(); UWLog.d("WXApp", msg); //重启 提示 } });