mpvue icon indicating copy to clipboard operation
mpvue copied to clipboard

v-model在自定义组件内部 不生效

Open luosijie opened this issue 6 years ago • 3 comments

v-model在自己的组件内部不生效

luosijie avatar Jun 15 '18 08:06 luosijie

父组件: <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 事件,并传入新值
      }
}

现出现无法输入,无法双向绑定

Kellercai avatar Jul 12 '18 05:07 Kellercai

请问解决了嘛

zihuachen110 avatar Apr 01 '22 02:04 zihuachen110

放心吧,我已经收到啦。

ANT-CYJ avatar Apr 01 '22 02:04 ANT-CYJ