效果:

上传后,隐藏+号,禁止继续上传;

移除当前已上传的后,重新显示+号,可以继续上传;

代码:

css : 隐藏上传的 + 号

变量:

注:
利用 hideUpload 控制 + 号的css
 
pngFilesList 为图片默认列表,(用于编辑时回显图片)

方法:

  // 上传成功时,让+号隐藏,不能再继续上传
  pngUpSuccess (response, file, fileList) {
this.ruleForm.pngUrl = response.data.path
this.hideUpload = true
this.$store.dispatch('setLoading', false)
},
pngUpError (file, fileList) {
this.$store.dispatch('setLoading', false)
},
  // 上传前限制类型和大小
pngBeforeUpload (file) {
this.$store.dispatch('setLoading', true)
const isPNG = file.type === 'image/png'
const isJPG = file.type === 'image/jpeg'
const isJPEG = file.type === 'image/jpeg'
const isLt2M = file.size / 1024 / 1024 < 2
if (!isPNG && !isJPG && !isJPEG) {
this.$message({
message: '不接受此文件类型!',
type: 'error',
showClose: true
})
this.$refs.uploadpng.clearFiles()
this.$store.dispatch('setLoading', false)
return false
}
if (!isLt2M) {
this.$message({
message: '图片大小不能超过2M',
type: 'error',
showClose: true
})
this.$refs.uploadpng.clearFiles()
this.$store.dispatch('setLoading', false)
return false
}
},
   // 移除文件后重新让 + 号 显示
pngonRemove () {
this.ruleForm.pngUrl = ''
this.hideUpload = false
},

最新文章

  1. es6 中增强的对象字面量
  2. Spring 定时器Quartz的用法
  3. for循环三个表达式的执行时间
  4. qt添加最小化和关闭按钮
  5. Weka算法Classifier-tree-J48源代码分析(一个)基本数据结构和算法
  6. org.apache.commons.httpclient
  7. 问题记录:android.os.NetworkOnMainThreadException异常
  8. GS连接事件
  9. C++不确定行为
  10. jQuery实现按键盘方向键翻页
  11. Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical
  12. 【2016北京集训测试赛(二)】 thr (树形DP)
  13. nginx session 配置失效解决
  14. P3402 最长公共子序列
  15. 微信破解,解密?How To Decrypt WeChat EnMicroMsg.db Database?
  16. 强化学习之Q-learning简介
  17. WebAPI Token 验证
  18. table中的td等长(不随内容大小变化)
  19. EXT 翻页后查询 页数不重置
  20. AngularJS 中的作用域

热门文章

  1. 函数:3ds max 给选择对象设置轴心点
  2. 复习第二点-2.基于注解的helloworld
  3. Excel列动态导出
  4. elementUI合并单元格
  5. 实验:两片ESP8266,分别做客户端和服务器,实现双向收发数据
  6. 常见报错——Uncaught TypeError: document.getElementsByClassName(...).addEventListener is not a function
  7. Spring 事务传播属性
  8. 5G工业智能网关助力智能制造开辟新赛道
  9. xh_零基础网站渗透第一部
  10. kafka配置内外网同时访问