如何将其他参数传递给上载按钮组件?威化

时间:2019-03-18 19:46:36

标签: file-upload vuejs2

我正在使用vuetify-upload-button组件来上传文件。使用仅获取文件加载的函数回调fileChangedCallback。 但是,我需要具有额外的参数才能做出逻辑。可以向该函数传递额外的参数吗?

这是我的代码:

v-flex.listFilesUpload(v-for="(file, index) in attachments" :key="index")
  p
    span
      | {{ index + 1 }}
  .btns-upload-download
    upload-btn(title="File" :fileChangedCallback="fileChanged" color="default")

import UploadButton from 'vuetify-upload-button'

export default {
  [..]
  methods: {
    fileChanged (file) {
      // Here I need my other variable file because it have the filename.
      if (file) {
        formData.append('filenames[]', file)
      }
    },
    components: {
      'upload-btn': UploadButton
    }
  }
}

0 个答案:

没有答案