Advertisement

将图片上传至云存储后自动渲染

阅读量:

记录 2020-07-29

图片上传功能实现

wxml

复制代码
    <button type="primary" bindtap="clickBtn">上传文件</button>
    
    
      
    

js

复制代码
    clickBtn(){
    wx.chooseImage({
      success:res=>{
        console.log(res)
       //回调成功之后得到临时路径
        var filePath=res.tempFilePaths[0]
        this.cloudFile(filePath)
      }
    })
      },
      cloudFile(path){
    wx.cloud.uploadFile({
      //上传要有两个参数,路径文件名
      cloudPath:Date.now()+".jpg",
      //临时路径filepath
      filePath:path
    }).then(res=>{
      console.log(res)
    })
      },
    
    
      
      
      

全部评论 (0)

还没有任何评论哟~