<script>
export default {
onLaunch: function(options) {
console.log("onLaunch",options);
if(options.query.scene){ //小程序码是否带有参数
//params转 obj 字符串参数 a=123&b=456 转 {a:"123",b:"456"}
var query=this.getRequestParameters(decodeURIComponent(options.query.scene))
console.log("onLaunch",query);
//对获取到的参数query进行下一步操作
}
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
methods:{
/*
* params转 obj 字符串参数
* 例子: a=1&b=2 => {a:1,b:2}
*/
getRequestParameters(params="") {
let theRequest = new Object();
if (params != undefined) {
let strs = params.split("&");
for (let i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
}
}
return theRequest;
},
}
}
</script>
网友评论