请教 input组件在不用触发(bindinput)方法也可以得到其值吗?
VM400:1 Component “pages/button1/button1” does not have a method “onSubmitOrder” to handle event “submit”. 我试过了,提示如上。
wmxl:
<form bindsubmit=“onSubmitOrder” bindreset=“onResetOrder”>
<view class=“sql-box”>
<input class=“sql-input” type=“digit” name=‘cell’ placeholder=“请输入手机号”></input>
<button class=“sql-btn” formType=“submit”>查询</button>
</view>
</form>
// pages/button1/button1.js
var a
var b
Page({
data: {
},
formSubmit: function (e) {
a= e.detail.value
console.log(“a=” + a)
},
})
利用form标签就可以了.
设置bindsubmit事件,
设置button类型为form-type=“submit”
为input指定name
才可以在form的事件中获取到数值:e.detail.value.cell
<form bindsubmit=“onSubmitOrder” bindreset=“onResetOrder”>
<view class=“sql-box”>
<input class=“sql-input” type=“digit” name=‘cell’ placeholder=“请输入手机号”></input>
<button class=“sql-btn” form-type=“submit”>查询</button>
</view>
</form>