Linux 拨号vps windows公众号手机端

小程序怎么在js中获取页面的值

lewis 7年前 (2018-12-11) 阅读数 12 #VPS/云服务器

小程序在js中获取页面的值案例:

在对应的wxml页面中添加以下代码:

<formbindsubmit='formsubmit'>

<viewclass='Type'>

<van-celltitle="类型"is-link>

<pickername="vtype"bindchange="bindTypeChange"value="{{TypeIndex}}"range="{{Types}}">

<viewclass="selectIndex1">{{Types[TypeIndex]}}</view>

</picker>

</van-cell>

</view>

<!--button按钮-->

<buttonclass="issue-btn"type="default"form-type='submit'>按钮</button>

</form>

在对应的js页面中添加以下代码:

Page({

data:{

Types:["宣传片","广告片","纪录片","短视频"],

TypeIndex:0,

},

//获取下标

bindTypeChange:function(e){

console.log('pickeraccount发生选择改变,携带值为',e.detail.value);

this.setData({

TypeIndex:e.detail.value

})

},

//表单提交按钮

formsubmit:function(e){

vartype=this.data.Types[this.data.TypeIndex];

//打印出来,看是否获取成功了

console.log('type:',type);

}

wx.redirectTo({

url:'/pages/payOrder/Contract/contract',

})

})

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门