<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>

Logo

前往低代码交流专区

更多推荐