第一步

找到你的txt文件,重命名为json文件
在这里插入图片描述

第二步

上传到云存储中,获取File ID
在这里插入图片描述

第三步

编写js代码
相关技术文档:
https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFile.html

onShow(){
  wx.cloud.downloadFile({
    fileID: 'cloud://xsl1-grzy6.7873-xsl1-grzy6-1259288832/管.json'
  }).then(res => {
    console.log(res.tempFilePath)
    let fs=wx.getFileSystemManager()
    let result = fs.readFileSync(res.tempFilePath,"utf-8")
    this.setData({
      allcontent: result
    })
  })
}

完成在这里插入图片描述

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐