1.先安裝node.js ;
注:a.一定確保node.js版本高于(v0.11.x)因為在Nodejs中使用ES6 generator是從v0.11.x開始獲得支持的,這個坑因為我的node.js是v0.10.x埋了一會兒的坑;b. 按照https://www.npmjs.com/package/weex-toolkit 確保 版本和工具都安裝好,特別是node-gyp 如果出現:
user "root" does not have permission to access the dev dir "/Users/
類似的錯
則執行
sudo chmod -R 777 /Users/lymin/.node-gyp
。
2.安裝Weex命令行程序 Weex Toolkit
npm install -g weex-toolkit #或前面加sudo
3.命令行窗口執行 weex 回車出現:
Usage: weex foo/bar/your_next_best_weex_script_file.we [options]
Options:
--qr display QR code for native runtime,
-o,--output transform weex we file to JS Bundle, output path (single JS bundle file or dir)
-s,--server start a http file server, weex .we file will be transforme to JS bundle on the server , specify local root path using the option
......
--help Show help
4.第三步通過后
<template>
<div class="container" >
<div class="cell">
<image class="thumb" src="http://t.cn/RGE3AJt"></image>
<text class="title">JavaScript</text>
</div>
</div>
</template>
<style>
.cell{margin-top:10 ; margin-left:10 ; flex-direction: row; }
.thumb {width: 200; height: 200; }
.title {text-align: center ; flex: 1; color: grey; font-size: 50; }
</style>
將上面的代碼保存為test.we文件
執行:
weex test.we
會在默認瀏覽器中打開頁面:
thumb_b0c40ee1bb6879b1979e283263458405.png
5.查看weex版本:
weex --version
#=> info 0.4.4