这里order-form.html是我想要跳转的html页面
decodeURIComponent() 可以解码URI特殊字符(如#,/,¥等),
而 decodeURI()则不能。
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
},
methods: {
// 卡片点击跳转事件
cardClick(val) {
// 这里如果需要传递中文记得加密
window.location.href = './order-form.html?id=123456&name=' + encodeURIComponent('张三');
},
},
});
在order-form.html中
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
},
created() {
this.getParams();
},
methods: {
getParams() {
var url = window.location.search;
console.log(decodeURIComponent(url)); //?id=123456&name=张三;
},
},
});
网友评论