微信小程序API之showActionSheet(操作菜单)
wxml:
<button bindtap="cd01">操作菜单01</button>
<button bindtap="cd02">操作菜单02</button>
js:
Page({
data: {
chengshi:["浙江","广东","北京"]
},
cd01:function(){
wx.showActionSheet({
itemList: ["A","B","C","D","E","F"], //数组最大长度为6
})
},
cd02:function(){
var tmp=this.data.chengshi;
wx.showActionSheet({
itemList: this.data.chengshi,
success(res){
console.log(res.tapIndex);
console.log(tmp[res.tapIndex]);
},
fail(res){
console.log(res.error);
}
})
}
})