vue iview 导入excel文件(upload) 4年前

<Upload 
                    ref="upload"
                    action="/api/book/excel/import"    
                    name="excel-file"
                    :show-upload-list="true"
                    :on-format-error="handleFormatError"
                    :on-success="handleSuccess"
                    :on-error="handleError"
                    :format ="['xlsx','xls']">
                        <Button type="info" icon="ios-cloud-upload-outline">批量导入</Button>
                </Upload>

 handleFormatError(file){
                this.$Notice.warning({
                    title: '文件格式不正确',
                    desc: '文件 ' + file.name + ' 格式不正确,请上传.xls,.xlsx文件。'
                })
            },
            handleSuccess(res,file){
                if(res.errcode === 0){
                    this.dialoLead = false
                    this.$Message.success("数据导入成功!")
                    this._getBookList()
                    this.$refs.upload.clearFiles()
                }
            },
            handleError(error,file){
                this.$Message.error("数据导入失败!")
            },
璇月
知道可能面对的困难和痛苦,在死亡的恐惧中不断挣扎,而仍然能战胜自己,选择这条道路,才是真正的勇气。
4
发布数
1
关注者
1755
累计阅读

热门教程文档

React
18小节
C++
73小节
MySQL
34小节
Golang
23小节
PHP
52小节
广告