mpx
mpx copied to clipboard
[Bug report]Vant Weapp的Field输入框组件的双向绑定无法工作
问题描述 输入的第一个字符会被删除,接下来输入的内容并没有赋值到绑定的变量,绑定的变量变成了undefined
复现步骤 测试代码
<template>
<view>
<van-cell-group>
<van-cell title="手机号" value="{{phoneNumber}}" />
<van-field
clearable
label="新手机号"
placeholder="请输入新手机号"
wx:model="{{newPhoneNumber}}"
error-message="{{phoneNumberError}}"
/>
</van-cell-group>
<view class="buttons">
<van-button size="large" type="primary" bind:click="changePhoneNumber"
>确定</van-button
>
</view>
</view>
</template>
<script>
import mpx, { createPage } from '@mpxjs/core'
createPage({
data: {
phoneNumber: '18600000001',
newPhoneNumber: '',
phoneNumberError: null,
},
changePhoneNumber: function () {
console.log('newPhoneNumber', this.newPhoneNumber)
if (!this.newPhoneNumber) {
this.phoneNumberError = '新手机号不能为空'
}
},
})
</script>
<style lang="stylus">
.buttons
margin 0 16px
.van-button
margin 16px 0 0
</style>
<script type="application/json">
{
"navigationBarTitleText": "修改手机号",
"usingComponents": {
"van-button": "@vant/weapp/dist/button/index",
"van-cell-group": "@vant/weapp/dist/cell-group/index",
"van-cell": "@vant/weapp/dist/cell/index",
"van-field": "@vant/weapp/dist/field/index"
}
}
</script>
期望的表现 输入的内容能完整的保存到绑定的变量
截图

系统及环境 用到的mpx和vant weapp版本是 "@mpxjs/core": "^2.5.11", "@vant/weapp": "^1.2.2",
附件
https://didi.github.io/mpx/single/template-enhance.html#%E5%8F%8C%E5%90%91%E7%BB%91%E5%AE%9A 看下双向绑定这一小节的最后一部分内容哈