在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ elementui上傳問題,急急急!!!!

elementui上傳問題,急急急!!!!

上傳的標(biāo)簽是這樣的寫的。

<el-upload
    class="upload-demo"
    ref="uploadNewFile"
    :action="actionUrl"
    :file-list="fileList"
    :auto-upload="false"
    :on-change="newFileChange"
    :on-remove="removeFile"
    :data="newFileData"
    name="files"
    :on-preview="handlePreview">
    <el-button type="primary" class="button b2 upload">
    <i class="iconfont icon-shangchuan"></i> 上傳
    </el-button>
    <el-input style="display: none" v-model="formData.newFile"></el-input>
</el-upload>

提交的時(shí)候

saveIt: function () {
                this.$refs['newAddForm'].validate((valid) => {
                    if(valid){
                        if (this.fileNameCheckFlag) {
                            this.newFileData.dictionaryName = this.formData.fileName;
                            this.newFileData.indexName = this.formData.fileName;
                            this.newFileData.isPublish = false;
                            this.newFileData.menuId = 256;
                            this.$refs['newAddForm'].resetFields();
                            this.zDialog.showAdd = false;
                            this.$refs.uploadNewFile.submit();
                            }
                    }

但是上傳文件提交的時(shí)候需要帶上 this.newFileData.title(文件名),和 this.newFileData.sort(文件排序號(hào));
請(qǐng)問上傳多個(gè)文件的時(shí)候文件名和文件排序號(hào)怎么賦值? 在哪里賦值?

回答
編輯回答
萌面人

newFileChange函數(shù)里面獲取文件并append title和sort
var file = document.querySelector('[type=file]');

       
       
        var formData = new FormData();
  
        formData.append('file', file.files[0]);
        formData.append('title','你的title')
        formData.append('sort','你的序號(hào)')
        this.fileList=[];
        this.fileList.push({
            name:file.files[0].name,
        })
       this.file=formData
2017年12月28日 19:19