gpt4 book ai didi

vue.js - Vuetify v-file-input "onchange"工作但没有收到事件

转载 作者:行者123 更新时间:2023-12-03 06:45:24 24 4
gpt4 key购买 nike

请看下面我的代码。我的 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 组件,它更漂亮。
提前致谢。

最佳答案

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

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

本次事件不同于 @change从您的输入。

关于vue.js - Vuetify v-file-input "onchange"工作但没有收到事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61947211/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com