使用element组件

1,分页数据处理

<el-pagination
            background
            layout="prev, pager, next"
            @current-change="handleCurrentChange"
            :page-size="9"
            :current-page.sync="pageNo"
            :total="parseInt(total)" //total的值要到后台获取
          ></el-pagination>

handleCurrentChange() {
      this.load();//这是要加载的函数
    }
//计算方法
computed: {
    pageNo: {
      get() {
        return Number(this.$route.query.pageNo || 1); //获取url上面pageNo的值
      },
      set(pageNo) {
        this.$router.push({
          query: { ...this.$route.query, pageNo }
        });
      }
    }
  },

2,文件上传组件upload —— 如何将文件传到后端

 <el-form-item label="" prop="expvmFiles">
           <el-upload
         class="upload-demo"
             drag
             ref="uploadfile"
            :action="upload_url"  
            :auto-upload="false"
             :before-upload="newFiles"
             multiple>
           <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
    <div slot="tip" class="el-upload__tip">实验信息附件上传,只能传(.file)文件</div>
         </el-upload>
       </el-form-item>
 <el-form-item label=""  prop="expvmVideo">
         <el-upload
            class="upload-demo"
            drag
             ref="uploadvideo"
            :action="upload_url"
          :auto-upload="false"
           :before-upload="newVideo"
           accept=".mp4">
            <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
           <div slot="tip" class="el-upload__tip">实验视频上传,只能传(.mp4)文件</div>
          </el-upload>
        </el-form-item>
data () {
     return {
     upload_url: 'aaa',       // 随便填一个,但一定要有
     uploadForm: new FormData(),   // 一个formdata
      rules: {},     // 用到的规则

     }
  }

methods:

  newSubmitForm () {
        this.$refs['newform'].validate((valid) => {
         if (valid) {
           this.uploadForm.append('expName', this.newform.expName)
           this.uploadForm.append('expSn', this.newform.expSn)
           this.uploadForm.append('groupId', this.newgroupId)
           this.uploadForm.append('subGroupId', this.newsubgroupId)
           this.uploadForm.append('expvmDifficulty', this.newform.expvmDifficulty)
           
          newExp(this.uploadForm).then(res => {
            if (res.code === 400) {
             this.$message.error(res.error)
            } else if (res.code === 200) {
               this.$message.success('上传成功!')
            
         }
        })
          this.$refs.uploadhtml.submit()   // 提交时触发了before-upload函数
         this.$refs.uploadfile.submit()
          this.$refs.uploadvideo.submit()
          
         } else {
        console.log('error submit!!')
         return false
         }
      })
    },
 newFiles (file) {
       this.uploadForm.append('file[]', file)
       return false
     }

newVideo (file) {
       this.uploadForm.append('video[]', file)
      return false
     }

select 筛选传值

 <el-select v-model="value" placeholder="状态" @change="selection"> 
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>

methods:

 selection() {
      console.log(this.value);
      this.unitsLoad();//需要加载的函数
    },
  const unit = await findListUnits(this.id, this.value);  //把值传给请求到的接口
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值