H5 game reception parameters created by COCOS Creator

It’s also my first contact with this stuff. It’s just a personal summary. I hope you don’t mislead you. Welcome to give me some advice.

onLoad: function () {
function GetRequest() {//This function is actually a js method. You can find the source in my blog.
var url = location .search; //Get the string after the "?" character in the url
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var strs = str.split("&");
for(var i = 0; i theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
var Request = new Object();//The usage is the same as pure js, you can print it if you don’t believe it
Request = GetRequest();
var id=Request["a"];
console.log("wxuser:"+id);

},

Look at the address bar Parameters, and the result printed in the lower right corner.

Magic language, think more Try, there will be results naturally.

It’s also my first contact with this stuff. It’s just a personal summary. I hope you don’t mislead you. Welcome Daniel to give me some advice.

onLoad: function () {
function GetRequest() {//This function is actually a js method. You can find the source in my blog.
var url = location .search; //Get the string after the "?" character in the url
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var strs = str.split("&");
for(var i = 0; i theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
var Request = new Object();//The usage is the same as pure js, you can print it if you don’t believe it
Request = GetRequest();
var id=Request["a"];
console.log("wxuser:"+id);

},

Look at the address bar The parameters and the result printed in the lower right corner.

Magic language, think more Try, there will be results naturally.

Leave a Comment

Your email address will not be published.