zoukankan      html  css  js  c++  java
  • uni-app(六)生成海报图片路径问题

      插件市场,搜索 painter 插件,这款插件很是强大,初次使用,存在一个问题,那就是由于跨域导致的图片路径问题

    • 如果是存储在服务器的图片,需要使用 downloadFile 获取图片路径,跳过跨域机制
      let that = this
      uni.downloadFile({
         url: that.img,
         success: function(res) {
             that.downloadPoster = res.tempFilePath
         },
         fail: function() {
             console.log('fail')
         }
      })
    • 下一步,需要用 getImageInfo 获取图片信息,输出可以直接使用的路径
      // 封装图片信息获取方法 
      promisify: promise => {
         return (options, ...params) => {
             return new Promise((resolve, reject) => {
                const extras = {
                    success: resolve,
                    fail: reject
                }
                promise({ ...options, ...extras }, ...params)
             })
          }
      }
      // 输出路径
      getPoster() {
          let that = this
          const getImageInfo = that.promisify(uni.getImageInfo)
          Promise.all([
             getImageInfo({
                src: that.downloadPoster
             })
          ]).then(res => {
             // 最终路径
             let path= res[0].path
             console.log(path)
          })
      }
  • 相关阅读:
    决策树
    结巴分词demo
    线性回归分析波士顿房价
    将python的字典格式数据写入excei表中
    ubuntu16.04电脑重启/关机卡死问题记录
    Hadoop 平台搭建
    Linux 常用命令
    灰度共生矩阵
    图像类型
    linux中的一些常用命令
  • 原文地址:https://www.cnblogs.com/wx3091/p/14550877.html
Copyright © 2011-2022 走看看