微信小程序獲取提交表單的值和修改文本值

一.頁面wxml設計代碼部分:

<view><form bindsubmit="formSubmit">

<input name="detail" value="{{inputValue}}" placeholder="詳情地址" />

<input name="realname" placeholder="收件人姓名" />

<input name="mobile" placeholder="手機號碼" type="number"/>

<button formType="submit" type="primary">Submit</button>

</form></view>

二.js控制值的處理代碼部分:

/**

* 頁面的初始數據

*/

data: {

//hiddenmodalput: true,

inputValue: null,

 

}

,

formSubmit: function (e) {

//在需要的地方調用setData,比如某button的觸發事件中

this.setData({

'inputValue': ' 已提交!!'

})

// detail

var detail = e.detail.value.detail;

console.log(detail);

// realname

var realname = e.detail.value.realname;

console.log(realname);

// mobile

var mobile = e.detail.value.mobile;

console.log(mobile);

e.detail.value.mobile='';

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章