function convertImageToBinary (fileInput) {
        return new Promise((resolve, reject) => {
          const reader = new FileReader()
          reader.onloadend = function () {
            const bytes = new Uint8Array(reader.result)
            resolve(bytes)
          }
          reader.onerror = reject
          reader.readAsArrayBuffer(fileInput)
        })
      }
      convertImageToBinary(file.raw).then(res => {
        console.log('res====>', res)
        const hexValue = Array.prototype.map
          .call(res, (x) => ('0x' + x.toString(16)))
          .join('')
        console.log('hexValue=--==>', hexValue)
      })

结果:
在这里插入图片描述

在这里插入图片描述

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐