zoukankan      html  css  js  c++  java
  • uniapp 上传图片

    1.  安装插件image-tools

    npm i image-tools --save
    import { pathToBase64, base64ToPath } from 'image-tools'

    2. 上传图片

    //选图片
                chooseImage() {
                    uni.chooseImage({
                        count: 100, //默认9
                        sizeType: ['compressed'], // 压缩图片
                        success: (res) => {
                            console.log(res)
                            res.tempFilePaths.forEach(item => {
                                this.imageList.push({
                                    mode: 'aspectFit',
                                    src: item
                                })
                            })
                        }
                    });
                },

    3. 转换图片

    this.imageList.forEach(item => {
      pathToBase64(item.src)
      .then(base64 => {
        this.pictures.push(base64)
      })
      .catch(error => {})
    })
  • 相关阅读:
    PKU 1860 Currency Exchange 最短路 bellman
    PKU 3259 Wormholes 最短路 bellman
    bzoj3514
    bzoj2594
    bzoj3901
    bzoj2843&&1180
    bzoj2631
    bzoj2049
    bzoj2002
    bzoj1146
  • 原文地址:https://www.cnblogs.com/guozongzhang/p/11940189.html
Copyright © 2011-2022 走看看