我正在制作一個帶有Vue.js的帖子,并試圖在點擊每個帖子時重定向頁面。我已經(jīng)安裝了vue-route和axios。在index.js中,export default new Router({ route: [ { path: '/', name: 'Post', component: Post }, { path: '/:req_no', name: 'Detail', component: Detail }, ]})在post.vue<div @click="detailPost(post.no)">{{post.title}}</div>...detailPost(req_no) { this.$router.push({ path: `https://dataURL/detail.php/${req_no}` }) }在Detail.vue中<template> <div> {{contents}} </div></template><script>import axios from 'axios';export default { name: 'Datail', data() { return { req_no: this.$route.params.req_no, contents: {} } }, created() { axios.get('https://dataURL/detail.php/', { params: { req_no: this.req_no } }).then(res => { this.contents = this.res.data }); }}</script>我不知道在哪里放url(在post.Vue,detailPost()或Detail.vue中的函數(shù)中)如果我把它放在功能中,我會得到 http://localhost:8080/#/http://dataURL/detail.php/2API指南說我必須使用參數(shù)。你能幫我解決一下嗎?非常感謝?。?
如何在單擊時將Vue.js重定向到不同的URL?
暮色呼如
2019-04-18 18:15:18