const app = getApp(); Component({ properties: { data:Object }, data: { }, methods: { preview(){ let url = global.config.eduUrl + this.data.data.url; if (this.data.data.content_type.startsWith("image")) { wx.previewImage({ urls: [url] }); return; } wx.showLoading({ title: '下载中', }) wx.downloadFile({ url, success: (res) => { wx.openDocument({ filePath: res.tempFilePath, fail: app.showError }); }, fail: app.showError, complete: wx.hideLoading }) } } })