1. 在小程序元素属性绑定值时,使用{{}}语法绑定变量
<img :src="imgSrc"></img>
<image src="{{imgSrc}}"></img>
2. 声明方法时,不用methods中声明,直接在data同级下声明函数
3. 在函数内修改data中的值
addCount(){
this.count++
}
addCount(){
this.setData({
count:this.data.count+1
})
},
4. 事件传参
<button :click="addCount(1)">按钮</button>
<button bindTap="addCount" data-i="{{1}}>按钮</button>
5. 条件判断
<view wx:if="{{type==1}}">男</view>
<view wx:elif="{{type==2}}">女</view>
<view wx:else>保密</view>
<view hidden="{{flag}}">hidden</view>
6. 循环
<view wx:for="{{arr}}">
索引:{{index}}--item:{{item}}
</view>
<view wx:for="{{arr}}" wx:for-index="idx" wx:for-item="tt">
索引:{{idx}}--item:{{tt}}
</view>