admin管理员组

文章数量:1530845

  • 在H5页面下载APP(apk)
    一般应用的方法是

window.location.href = 下载地址

downLoad () {
	this.downAndroid()
}
async downAndroid() {
	const res = await this.$http.get('/api/params')
	if (res.code !==0) {
		return uni.showToast({
			title:res.msg,
			icon:'none'
		})
	}
	const url = res.data.data.appDownLoad
	if( url ){
	
		window.location.href = url
	}
},
  • uniapp的API ---- 下载

一般用于app,h5网页端不大适用。其中下载地址为临时路径还需要保存临时路径。相对于window.location.href 而言 window更为适用于下载apk

uni.downloadFile({
    url: 'https://www.example/file/test', //仅为示例,并非真实的资源
    success: (res) => {
        if (res.statusCode === 200) {
            console.log('下载成功');
        }
    }
});

本文标签: 网页方法appapk