hookehuyr

修改新闻中心路由参数跳转操作

/*
* @Date: 2024-08-26 10:42:15
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-12-10 16:01:00
* @LastEditTime: 2024-12-12 12:47:30
* @FilePath: /hager/src/route.js
* @Description: 文件描述
*/
......@@ -141,7 +141,7 @@ export default [{
},
children: []
}, {
path: '/news/detail',
path: '/news/detail/:id',
name: '新闻详情',
component: () => import('@/views/news/detail'),
meta: {
......
<!--
* @Date: 2024-08-27 10:06:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-12-11 15:16:27
* @LastEditTime: 2024-12-12 12:48:04
* @FilePath: /hager/src/views/index.vue
* @Description: 首页
-->
......@@ -308,10 +308,7 @@ export default {
},
goToNew (v) {
this.$router.push({
path: '/news/detail',
query: {
id: v.id
}
path: `/news/detail/${v.id}`,
});
},
goToNews () {
......
<!--
* @Date: 2024-10-18 12:06:09
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-12-04 18:16:02
* @LastEditTime: 2024-12-12 12:49:20
* @FilePath: /hager/src/views/news/detail.vue
* @Description: 文件描述
-->
......@@ -52,7 +52,7 @@ export default {
}
},
async mounted () {
const { code, data } = await getNewsDetailAPI({ id: this.$route.query.id });
const { code, data } = await getNewsDetailAPI({ id: this.$route.params.id });
if (code) {
this.title = data.post_title;
this.content = data.product_advantages;
......
<!--
* @Date: 2024-10-18 12:05:44
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-12-03 16:26:23
* @LastEditTime: 2024-12-12 12:48:45
* @FilePath: /hager/src/views/news/index.vue
* @Description: 文件描述
-->
......@@ -87,10 +87,7 @@ export default {
methods: {
goToNew (v) {
this.$router.push({
path: '/news/detail',
query: {
id: v.id
}
path: `/news/detail/${v.id}`,
});
},
async getMore () {
......
<!--
* @Date: 2024-10-20 16:57:48
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-12-04 16:00:08
* @LastEditTime: 2024-12-12 12:48:21
* @FilePath: /hager/src/views/search.vue
* @Description: 文件描述
-->
......@@ -238,10 +238,7 @@ export default {
},
goToNews (id) {
this.$router.push({
path: '/news/detail',
query: {
id: id
}
path: `/news/detail/${id}`,
});
},
goToDetail (v) { // 跳转产品详情
......