Weex安装

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

详细请参见:< https://github.com/weexteam/article/issues/4 >< http://www.jianshu.com/p/507471016928 >

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容