0
私はVueとAxiosを使ってプログレスバーを表示しています。 uploadProgress
は、私のVueインスタンスのデータキーです。内部関数を使って設定しようとすると、定義されていません。ここに私のコードの簡易版です:Vue:「内部」機能からデータを設定するにはどうすればよいですか?
someVueMethod() {
this.uploadProgress = 0 // this works
let config = {
onUploadProgress(progress) {
// this doesn't work, error says uploadProgress is undefined
this.uploadProgress += progress.loaded/progress.total
}
}
axios.put(url, file, config).then(res => {
// handle the response
})
}
私はその内側の関数内からuploadProgress
を設定できますか?
はい!ありがとうございました。私はいくつかの同様のアプローチを試して、その中でコンテキストを取得しようとしましたが、それを得られませんでした。これは完全に機能しました。ありがとう! – Alan