列表渲染wx:for
index————》索引(下标) item————》对应每一项 默认值
<view wx:for="{{arr}}">
{{index}}: {{item}}
</view>
<view wx:for="{{arr}}" wx:for-index="idx" wx:for-item="itemName">
{{idx}}: {{itemName}}
</view>
wx:if 多条件判断
<view wx:if="{{a}}">单个条件</view>
<view wx:if="{{a || b}}">多个或条件</view>
<view wx:if="{{a && b}}">多个且条件</view>
wx:if wx:elif wx:else
以下是常见的false
false
undefined
null
0
-0
NaN
" "
JS中的数据类型
Object
Array
Function
string
boolean
null
undefined
smybol
微信小程序的事件
<button open-type="getUserInfo" bindgetuserinfo="getuserinfo">获取用户信息</button>
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">获取手机号</button>
<button bindtap="openSetting">打开设置页</button>
list: ['scope.userInfo', 'scope.userLocation', 'scope.address', 'scope.invoiceTitle', 'scope.werun',
'scope.record', 'scope.writePhotosAlbum', 'scope.camera']
wx.getSetting({
success: (response) => {
if (!response.authSetting[str]) {
wx.authorize({
scope: str,
success: () => {
console.log('授权成功')
}
})
}
}
})