Saturday, October 1, 2022
HomeiOS Developmentjavascript - How can I get the information I need from an...

javascript – How can I get the information I need from an url handle


I had a VUE web page that bounce from Native aspect, in an effort to get the api prams I need, Native aspect passing the information as a url type like
file:///storage/emulated/0/Android/information/com.hon.smarthome/information/w…tail_base/index.html?iotId=xdN3ywsqvJu2tHgY4mOf000000&platform=1#/primary

the 1 and xdN3ywsqvJu2tHgY4mOf000000 is the information I need
So I exploit cut up to get these information

var url = window.location.href; 
var cutNumberSign = url.cut up('#')[0];
var iotIdPlusPlatform = cutNumberSign.cut up('?')[1];
var cutIotId = iotIdPlusPlatform.cut up('iotId=')[1];
var platfrom = cutIotId.cut up('platform=')[1];
var iotId = cutIotId.cut up('&')[0];
this.iotId = iotId;
this.platform = platfrom;

It really works completely wonderful from Android aspect
Nevertheless from ios I received, the information order was not the identical, it was like
index.html?platform=1&iotId=xdN3ywsqvJu2tHgY4mOf000000#/primary

so the cut up won’t work,
How am i able to get these information irrespective of the order is?
Thanks

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments