前言
环境搭建
1. weex-toolkit
2. node
3. weexpack
4. weextools
brew install node
npm install -g weex-toolkit
npm install -g weexpack
npm 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 demo
weexpack create demo1
weextools create demo2
项目
官方demo:weex-hackernews
解读
components ——vue组件
views ——视图
store ——Vuex
mixins——扩展
filters——vue.js 的filter
App.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. ucar-weex Android 集成
3. weex集成ucar-weex
npm install ucar-weex --save
- ucar-weex 基础api
项目调试
npm run dev
weex 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);
//重启 提示
}
});
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。