vue动态(type可变)input绑定

时间:2018-02-03 16:19:45   收藏:0   阅读:6019

遇到如下错误:

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

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!