0

vue-simple-uploader的文档中没有找到回调response,也没有找到类似的函数。希望能够得到指导。

查看全部 2 个回答

1

已采纳

<template>
<uploader :options="options" :file-status-text="statusText" class="uploader-example" ref="uploader" @file-success="fileSuccess"></uploader>
</template>
<script>
export default {

data () {
  return {
    options: {
      target: '//localhost:3000/upload', // '//jsonplaceholder.typicode.com/posts/',
      testChunks: false
    },
    attrs: {
      accept: 'image/*'
    },
    statusText: {
      success: '成功了',
      error: '出错了',
      uploading: '上传中',
      paused: '暂停中',
      waiting: '等待中'
    }
  }
},
methods: {
//上传成功的事件
fileSuccess (rootFile, file, message, chunk) {
  console.log('complete', rootFile, file, message, chunk)
}
},
mounted () {
// 获取uploader对象
  this.$nextTick(() => {
    window.uploader = this.$refs.uploader.uploader
  })
}

}
</script>