美文网首页
js file to base64

js file to base64

作者: 草帽lufei | 来源:发表于2019-11-04 14:30 被阅读0次

vuetity v-file-input

<v-file-input label="File input" @change="fileChange" v-model="file"></v-file-input>
<img :src="image" style="width:100%;height:200px;object-fit: cover;" />

js

    fileChange () {
      console.log('fileChange ')
      console.log(this.file)
      let reader = new FileReader()
      let self = this
      reader.readAsDataURL(this.file)
      reader.onload = function (e) {
        let dataBase64 = reader.result
        console.log(dataBase64)
        self.image = dataBase64
      }
    }

js base64 to file

相关文章

网友评论

      本文标题:js file to base64

      本文链接:https://www.haomeiwen.com/subject/hhhdbctx.html