vue动态(type可变)input绑定

遇到如下错误:

v-model does not support dynamic input types

解决方法:

vue 2.5.0以上,支持动态绑定

<input :type="type" :name="name" :id="name" v-model="inputVal">

vue 2.5.0以下,可以使用v-if来做

<input v-if="type == 'text'" type="text" :name="name" :id="name" v-model="inputVal">
<input v-if="type == 'number'" type="number" :name="name" :id="name" v-model="inputVal">

 

 

出处:https://stackoverflow.com/questions/44461188/vue2-v-model-does-not-support-dynamic-input-types

 

posted @ 2018-02-03 12:53  全玉  阅读(2594)  评论(0编辑  收藏  举报