Taro微信小程序報錯: downloadFile:fail createDownloadTask:fail url not in domain list

點擊下載文件提示錯誤:downloadFile:fail createDownloadTask:fail url not in domain list
配置好request合法域名downloadFile合法域名,可以在微信開發工具中:詳情->域名信息中查看是否已經配置,若沒有配置請登錄微信公衆號進行配置

handleDownloadFile = () => {
    const ticket = this.props.caseDto.caseData.ticket;
    const url = `https://example.weixin.com/downloadFile`   // 非真實的接口地址
    Taro.downloadFile({
      url: url,
      success: function(res) {
        var filePath = res.tempFilePath;
        Taro.openDocument({
          filePath: filePath,
          fileType: "pdf",
          success: function(res) {
            Taro.showToast({
              title: '文檔打開成功',
              icon: 'success',
              duration: 2000
            })
            console.log("文檔打開成功");
          },
          fail: function (res) {
            Taro.showToast({
              title: '文檔打開失敗',
              icon: 'none',
              duration: 2000
            })
          },
        });
      },
      fail: function (res) {
        Taro.showToast({
          title: '文檔下載失敗',
          icon: 'none',
          duration: 2000
        })
      }
    });
  };
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章