Skip to content

和vue一起使用报错 #11

Description

@assmdx
fileChange(el){`
      let that = this
      for(let i = 0; i < el.target.files.length;i++){
        // that.gallery.push(el.target.files[i])
        new html5ImgCompress(el.target.files[i], {
          before: function(file) {
            console.log('压缩前...');
            // console.log(typeof that.gallery)
            // 这里一般是对file进行filter,例如用file.type.indexOf('image') > -1来检验是否是图片
            // 如果为非图片,则return false放弃压缩(不执行后续done、fail、complete),并相应提示
          },
          done: function(file, base64) {
            console.log('压缩成功...');
            console.log(typeof that.gallery);
            // ajax和服务器通信上传base64图片等操作
            that.gallery.push(file)
          },
          fail: function(file) {
            console.log('压缩失败...');
          },
          complete: function(file) {
            console.log('压缩完成...');
          },
          notSupport: function(file) {
            console.log('浏览器不支持!')
            // 不支持操作,例如PC在这里可以采用swfupload上传
          }
        },false)
      }
    }

和vue一起使用,在chrome浏览器环境下。
这是我的监听input的代码,无法进入到done中,也不会跳转到notSupport,只是执行before之后就报错:
Uncaught SyntaxError: Unexpected token <

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions