mpvue
mpvue copied to clipboard
v-model在自定义组件内部 不生效
v-model在自己的组件内部不生效
父组件:
<cp-input type="password" v-model="psw" placeholder="请输入密码"/>
子组件:
<input ref="input"
:value="currentValue"
:placeholder="placeholder"
:placeholder-class="placeholderClass"
:focus="focus"
:disabled="disabled"
:maxlength="maxlength"
@input="handleInput"
@blur="handleBlur"
@focus="handleFocus"/>
computed: {
currentValue: function () {
return this.value
}
},
methods: {
handleInput (e) {
if (this.disabled) return
console.log(e)
var value = e.mp.target.value;
this.$emit('input', value); // 触发 input 事件,并传入新值
}
}
现出现无法输入,无法双向绑定
请问解决了嘛
放心吧,我已经收到啦。