zoukankan      html  css  js  c++  java
  • vue 上传文件

    <input type="file" ref="files" style=" 268px;" />
     
    <el-button class="submitBtn" type="primary" @click="submitForm($event)">确认发送权益</el-button>
     
     methods: {
            submitForm() {
                let fileVal = this.$refs.files.value;
                if (fileVal == '' || fileVal == null || !fileVal) {
                    this.$message.error('请选择您要上传的文件');
                    return false
                }
                let file = this.$refs.files.files[0];
                let dataFile = new FormData();
                dataFile.append('file_upload', file)
                let config = {
                    headers: { 'Content-Type': 'multipart/form-data', 'Authorization': this.$cookie.get('Authorization') }
                };
                const instance = this.$axios.create({
                    withCredentials: true
                })
                instance.post('/admin/adminCoupon/importCoupon.json', dataFile, config).then(res => {
                    const data = res.data;
                    if (data.success) {
                        fileVal = ''; // 清空表单
                        this.$message.success('上传成功');
                        return false
                    } else {
                        this.$message.error(data.message);
                        return false
                    }

                }).catch(err => {
                    this.$message.error('服务异常,请重试');
                    return false
                })
            }
        }

  • 相关阅读:
    NET Attribute
    net core HttpClient
    Nuget服务器
    JS-防抖节流
    Codeforces,Topcoder,SGU,Timus,ProjectEuler
    并发编程,高速缓存,原子操作,指令重排序
    C编译器的编译过程主要分成四步: (1) 预处理 (2) 编译 (3) 汇编 (4) 连接
    C#--Distinct
    PageRank算法的思想
    ML.NET 发布0.11版本:.NET中的机器学习,为TensorFlow和ONNX添加了新功能
  • 原文地址:https://www.cnblogs.com/king94Boy/p/11578376.html
Copyright © 2011-2022 走看看