首页 > 解决方案 > 为什么,当您在 v-select 之外单击时,v-model 会重置为 null?验证

问题描述

此错误出现在带有 Vuetify 1.5.14 和 Vue 2.x 的 IE11 中。我正在使用 v-select 组件,如下所示:

form#login-form
  v-select#inputTypeDocument(:items = 'type_documents' required v-model='form.typeDocument' placeholder='Type of document')

export default {
   data () {
     return {
       form: {
         typeDocument: 2,
         numberDocument: '',
         password: ''
       },
       type_documents: [
         {text: 'Type 1', value: 1},
         {text: 'Type 2', value: 2}
       ]
     }
   }
}

并且在IE11中测试,当你改变v-select的值并点击组件外部或者按tab时,v-model的值被重置为null。而且我还有其他行为相同的 v-select。

在我的 main.js 文件中,我有如下 polyfill:

import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import axios from 'axio
[..]

在 IE11 中使用 v-select 组件是否有解决此问题的方法?

标签: vuejs2internet-explorer-11vuetify.jsv-modelv-select

解决方案


即使使用这个“修复”——你可能在使用VuetifyIE11 时遇到更多麻烦。 Vuetify已知不适用于 IE11..

注意:我还必须babel-polyfill与这个“修复”一起使用..

话虽如此,我已经测试/验证了这个“修复”:

    <v-select id="input" 
        :items="type_documents" 
        required 
        v-model="form.typeDocument" 
        :placeholder="form.typeDocument ? undefined : 'Type of document'">
    </v-select>

具体来说,这一行:

:placeholder="form.typeDocument ? undefined : 'Type of document'">

信用


推荐阅读