- 31
- 0
上传图片的功能不能上传两张一样的图片,方法如下,感谢各位 openImg(item2, el, index, field, indexId, level, type) { ;(this.clickTagValue = item2), (this.clickTagField = field), (this.clickTagIndexId = indexId), (this.clickTagLevel = level), (this.clickTagType = type), (this.isArrayclickTagType = type), localStorage.setItem('skuTable', JSON.stringify(this.skuTable)) console.log( item2, el, index, field, indexId, level, type, 'ooooooooooooooo' ) this.imgsObj[item2.specItem] = item2.image // console.log(item2.specItem,index,'item2222222222'); this.chooseImgItem = item2.specItem this.chooseIndex = index this.imgLoopList = item2 this.apiImgLoopList = item2 if (inputElement === null) { // 生成文件上传的控件 inputElement = document.createElement('input') inputElement.setAttribute('type', 'file') inputElement.style.display = 'none' if (window.addEventListener) { inputElement.addEventListener('change', this.uploadFile, false) } else { inputElement.attachEvent('onChange', this.uploadFile) } document.body.appendChild(inputElement) // this.createTableListRowData() } inputElement.click() // this.createTableListRowData(); }, uploadFile(el, value, field, indexId, level, type) { console.log( el, value, field, indexId, level, type, 'uploadfile===========' ) if (el && el.target && el.target.files && el.target.files.length > 0) { this.files = el.target.files[0] const files = el.target.files[0] const isLt2M = files.size / 1024 / 1024 < 2 const size = files.size / 1024 / 1024 console.log(size) // 判断上传文件的大小 if (!isLt2M) { this.$message.error('上传头像图片大小不能超过 2MB!') } else if (files.type.indexOf('image') === -1) { //如果不是图片格式 // this.$dialog.toast({ mes: '请选择图片文件' }); this.$message.error('请选择图片文件') } else { let that = this const reader = new FileReader() // 创建读取文件对象 reader.readAsDataURL(el.target.files[0]) // 发起异步请求,读取文件 // console.log(window.URL.createObjectURL(files),'files1111111111111111111111') // this.previewImage = window.URL.createObjectURL(files); reader.onload = function() { // 文件读取完成后 // 读取完成后,将结果赋值给img的src that.imgLoopList.image = URL.createObjectURL(files) that.uploadType = '图片上传完成' // that.clickTag( // that.clickTagValue, // that.clickTagField, // that.clickTagIndexId, // that.clickTagLevel, // that.clickTagType, // that.uploadType // ) } } } },
0
打赏
收藏
点击回答
- 共 0 条
- 全部回答
更多回答
网站公告
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部

