1.创建weex工程
搭建好环境以后,进入命令行创建weex工程
weex create helloWeex;//新建工程
后面会紧跟一系列的要你确认的步骤,比如工程名,作者,是否使用lint等,一个个的选就行了
选完之后会提示:
Success! Created helloWeex at /Users/rookie/WorkFile/workspace/WeexProjects/DemoSpace/helloWeex
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 intoweb/build
folder
npm run test
Starts the test runner
To get started:
cd helloWeex
npm start
Enjoy your hacking time!
看到这个提示,你的工程就算创建ok,然后,进入项目目录
cd helloWeex
npm start
以上,就会在默认的浏览器打开demo页面了,如下图:
2.添加平台支持
weex可以添加Android或者ios支持,语法如下:
weex platform add android;//添加Android平台
weex platform add ios;//添加ios平台
添加ok后,运行如下命令即可分别在ios或者Android平台上面运行了
weex run ios;
weex run android;