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


I had a VUE web page that leap from Native aspect, with a view to get the api prams I need, Native aspect passing the info as a url kind like
file:///storage/emulated/0/Android/information/com.hon.smarthome/recordsdata/w…tail_base/index.html?iotId=xdN3ywsqvJu2tHgY4mOf000000&platform=1#/foremost

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

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

It really works completely advantageous from Android aspect
Nonetheless from ios I bought, the info order was not the identical, it was like
index.html?platform=1&iotId=xdN3ywsqvJu2tHgY4mOf000000#/foremost

so the break up is not going to work,
How am i able to get these information irrespective of the order is?
Thanks

Similar Posts

Leave a Reply

Your email address will not be published.