hash模式路由参数接受

h5
wangdong 5 months ago
parent 1d173bb8e2
commit aaeeb7e1d0
  1. 11
      App.vue
  2. 2
      manifest.json

@ -17,7 +17,7 @@
onLaunch({ path, query, scene }) { onLaunch({ path, query, scene }) {
console.log(this.$route); console.log(this.$route);
// #ifdef H5 // #ifdef H5
const storeId = this.$route.query.storeId; const storeId = this.getQueryString('storeId');
console.log(storeId); console.log(storeId);
uni.setStorageSync('storeId', storeId || ''); uni.setStorageSync('storeId', storeId || '');
// #endif // #endif
@ -43,6 +43,15 @@
methods: { methods: {
getQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
},
// app // app
onStartupQuery(query) { onStartupQuery(query) {
// //

@ -153,7 +153,7 @@
} }
}, },
"router" : { "router" : {
"mode" : "history", "mode" : "hash",
"base" : "./" "base" : "./"
}, },
"devServer" : { "devServer" : {

Loading…
Cancel
Save