最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html打包apk指定参数,uni

运维笔记admin15浏览0评论

html打包apk指定参数,uni

html打包apk指定参数,uni

业务前景:

采用uni-app开发的项目 发型打包生成 H5-手机版 单页面应用 打包出来的总入口页面是index.html

业务需求:

在外界直接打开index.html 总入口页面时需要传递参数及获取参数 用于区分渠道来源或分享标记

相关尝试:

this.$route.query this.$route.params 等操作无效 获取不到首页面的参数

解决方案:

在App.vue 应用生命周期的 onLaunch()中采用JS直接提取链接参数 然后针对参数进行拆分

如:.html?sceneid=h5&wxcode=xxx&puid=fff

onLaunch(){

let tmpUrlSearch = window.location.search;// 得到:?sceneid=h5&wxcode=xxx&puid=fff

let tmpParas=GetRequestParameters(tmpUrlSearch);

let tmpSceneID = tmpParas["sceneid"];//提取参数

};

网上抄的一段儿方法:

export const GetRequestParameters=(locationsearch) =>{

let url = locationsearch;

let theRequest = new Object();

if (url.indexOf("?") != -1) {

let str = url.substr(1);

let strs = str.split("&");

for (let i = 0; i < strs.length; i++) {

theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);

}

}

return theRequest;

}

发布评论

评论列表(0)

  1. 暂无评论