second.vue
<!-- 点击el-row 跳转到/artistDetails 页面 -->
<el-row v-for="(item,index) in list" :key="index" @click.native="artClick(item)">
<el-col></el-col>
</el-row>
artClick(item) {
this.$router.push({
// 优化 刷新网页 获取不到数据 页面为空的问题
path: "/artistDetails" + "?content_id=" + item.content_id + "&sourc_site=" + item.sourc_site + "&source=" + item.source + "&name=" + item.title,
});
},
artistDetails.vue
mounted() {
this.initRequest()
},
methods: {
// 获取url地址中的参数
initRequest() {
var url = window.location.href.split("?");
if (url.length > 1) {
var theRequest = new Object();
var strs = url[1].split("&");
for (var i = 0; i < strs.length; i++) {
// decodeURI() 解决js获取url中的中文参数出现乱码 之前用了unescape()会出现乱码
theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
}
this.theUrlParame = theRequest // theUrlParame 定义在data中 以后使用会比较方便
return theRequest;
} else {
return null;
}
},
}