微信小程序开发之 js页面获取wxml页面中picker,input的值
程序员文章站
2024-02-15 09:36:10
...
wxml页面:
<form bindsubmit='formsubmit'>
<view class='Type'>
<van-cell title="类型" is-link>
<picker name="vtype" bindchange="bindTypeChange" value="{{TypeIndex}}" range="{{Types}}">
<view class="selectIndex1">{{Types[TypeIndex]}}</view>
</picker>
</van-cell>
</view>
<!-- button按钮 -->
<button class="issue-btn" type="default" form-type='submit'>按钮</button>
</form>
js页面:
Page({
data: {
Types: ["宣传片", "广告片", "纪录片", "短视频"],
TypeIndex: 0,
},
//获取下标
bindTypeChange: function (e) {
console.log('picker account 发生选择改变,携带值为', e.detail.value);
this.setData({
TypeIndex: e.detail.value
})
},
//表单提交按钮
formsubmit: function (e){
var type = this.data.Types[this.data.TypeIndex];
//打印出来,看是否获取成功了
console.log(' type :', type);
}
wx.redirectTo({
url: '/pages/payOrder/Contract/contract',
})
})
来看效果
选择类型为纪录片:
Console控制台打印结果:
上一篇: Photoshop脚本编程简介