element 上传 点击后直接调起文件选择

element el-upload 上传 点击后直接调起文件选择 (或上传)

成品展示
1.未点击时(默认情况,点击红框直接调起文件选择:下图)
未点击默认
2.点击时 (红框被点击,调起文件选择)
在这里插入图片描述
3.如果符合你的需求看代码👇

代码

html部分

      <div  style="width: 270px;height: 150px;overflow: hidden">
        <el-upload
          action="string"
          :auto-upload="false" :on-change="handleWxLoad"
          :show-file-list="false">
          <el-image v-if="!File[0].url" style="width: 120px; height: 120px"
                :src="require('@/assets/images/showWxQrcode.png')">
          </el-image>  // 为空时使用默认图
          <img v-else style="width: 120px;height: 120px;overflow: hidden"
        :src="File[0].url" alt="">
        </el-upload>
     </div>

Js部分

	handleWxLoad(file) {
	//转64
	  this.getBase64(file.raw).then(res => {
		return this.File[0].url = res
	  });  //
	  //转64
	  this.File.push(file.raw); //文件格式
	},

方法 this.getBase64()在这里

css部分 必须要修改 (删除的蒙板 del 按键)


	::v-deep  无效 可换成 /deep/
	 // del删除文件
	::v-deep .el-upload-list__item.is-success.focusing .el-icon-close-tip {
		display: none !important;
	}
	// 删除的蒙版和事件
	::v-deep .el-icon-delete {
	  display: none;
	}

	::v-deep .el-upload-list__item-delete {
	  display: none;
	}

	::v-deep .el-upload-list--picture-card .el-upload-list__item-actions {
	  background-color: transparent;
	}

都看👓完了,就👍1️⃣👇吧
♥ 希望帮助到你 ♥

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值