【问题标题】:Vuetify v-file-input "onchange" working but not getting the eventVuetify v-file-input“onchange”工作但没有得到事件
【发布时间】:2020-05-22 03:08:38
【问题描述】:

请看我下面的代码。我的input 运行良好,但v-file-input 不行:

<v-file-input
  accept=".json"
  ref="loadedFile"
  label="Upload file"
  @change="checkJSON"
  ></v-file-input>

<input
    type="file"
    accept=".json"
    @change="checkJSON"
    >



methods: {
  checkJSON: function(e) {
    console.log("JSON checking")
    console.log(JSON.stringify(e))
    console.log(e.target.files)
    return
  }
}

控制台显示input 的文件,但这是我收到的v-file-input 的消息:

[Vue warn]: Error in v-on handler: "TypeError: e.target is undefined"

这正常吗?我想使用 vuetify 组件,它更漂亮。 提前致谢。

【问题讨论】:

    标签: vue.js vuetify.js


    【解决方案1】:

    根据Vuetify docv-file-input@change 事件有 1 个参数,它是一个文件数组。

    checkJSON: function(files) {
        console.log(files)
    }
    

    此事件与您输入的 @change 不同。

    【讨论】:

    • 谢谢,我不明白他们所说的“文件[]”是什么意思。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-18
    • 2022-08-22
    • 1970-01-01
    • 2020-01-06
    • 1970-01-01
    相关资源
    最近更新 更多