概述
项目场景:
使用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)
},
最后
以上就是鳗鱼蚂蚁为你收集整理的解决第三方组件函数传值问题项目场景:问题描述原因分析:解决方案:的全部内容,希望文章能够帮你解决解决第三方组件函数传值问题项目场景:问题描述原因分析:解决方案:所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复