解决第三方组件函数传值问题

13 篇文章 0 订阅

项目场景:

使用elementUi的upload组件进行附件预览时,on-preview不传参就是默认的附件信息,如果我们想传递不同的值进行判断预览 怎么办呢?

问题描述

使用elementUi的upload组件进行附件预览时,on-preview不传参就是默认的附件信息,如果我们想传递不同的值进行判断预览,普通的vue写法传参会导致代码自动执行,解决不了问题 。

 :on-preview="e => handlePreview(e, citem,formValueNew['formValueNew' + index][cindex])"

原因分析:

提示:这里填写问题的分析:

暂时未知


解决方案:

提示:这写成箭头函数;在vue中使用的少往往会被忽略的一种传参方式

:on-preview="e => handlePreview(e, citem,formValueNew['formValueNew' + index][cindex])"

// 展示图片
    handlePreview(e,type,file) {
      this.Visible = true
      console.log(e,type,'kkkkkk')
      if(type&&type.fileType){
        const { status, url } = file[0]
         if(type.fileType=='image'){
            this.fileType = 'image'
        }else{
            this.fileType = 'video'
            this.fileList[0] = url
        }
         if (status == 'success') {
        this.fileUrl = url
        this.currentFileUrl = url

      }
      }else {
          const { status, url } = e
        let fileType = url.substring(url.lastIndexOf('.') + 1)
        if(fileType == 'mp4'){
         this.fileType = 'video'
         this.fileList[0] = url
        }else{
          this.fileType = 'image'
        }
        if (status == 'success') {
        this.fileUrl = url
        this.currentFileUrl = url
        this.fileList[0] = url
      }

      }
       console.log(e,type,file,this.fileList[0],'this.fileList[0]============',this.fileType,this.currentFileUrl)

    },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值