經過上一章講解,咱們瞭解到如何初始化一個小程序項目,這裏是官方給到demo地址,經過demo來看教程更方便於咱們理解項目架構。javascript
由四種文件構成:html
json配置:前端
{ "pages":[ "pages/index/index", "pages/logs/logs" ], "window":{ "backgroundTextStyle":"light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "WeChat", "navigationBarTextStyle":"black" } }
WXML,WXSS,JS模版java
<view class="container"> <view class="userinfo"> <button wx:if="{{!hasUserInfo && canIUse}}"> 獲取頭像暱稱 </button> <block wx:else> <image src="{{userInfo.avatarUrl}}" background-size="cover"></image> <text class="userinfo-nickname">{{userInfo.nickName}}</text> </block> </view> <view class="usermotto"> <text class="user-motto">{{motto}}</text> </view> </view>
//WXML <view>{{ msg }}</view> <button bindtap="clickMe">點擊我</button> //JS Page({ clickMe: function() { this.setData({ msg: "Hello World" }) } })