vue頁面不能根據(jù)路徑進行跳轉(zhuǎn)的解決方法
源碼
app.vue文件
<template>
<div id="app">
</div>
</template>
<script>
export default {
name: 'app',
}
</script>
<style>
</style>
import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/homeView',
name: 'homeView',
component: HomeView
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
}
]
const router = new VueRouter({
routes
})
export default router
問題現(xiàn)象
我們創(chuàng)建了很多個頁面,并且在路由文件補充頁面的跳轉(zhuǎn)路徑。但在瀏覽器的地址欄輸入不用鏈接,卻不能訪問相應(yīng)的頁面。
原因
vue沒有渲染頁面
解決
在app.vue補充
<template>
<div id="app">
<!--補充的內(nèi)容-->
<router-view/>
<!--補充結(jié)束-->
</div>
</template>
<script>
export default {
name: 'app',
}
</script>
<style>
</style>到此這篇關(guān)于vue頁面不能根據(jù)路徑進行跳轉(zhuǎn)的解決方法的文章就介紹到這了,更多相關(guān)vue 路徑跳轉(zhuǎn)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue中style設(shè)置scoped后部分樣式不生效的解決
這篇文章主要介紹了vue中style設(shè)置scoped后部分樣式不生效的解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-09-09
Vue項目打包壓縮的實現(xiàn)(讓頁面更快響應(yīng))
這篇文章主要介紹了Vue項目打包壓縮的實現(xiàn)(讓頁面更快響應(yīng)),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-03-03
淺談vue中數(shù)據(jù)雙向綁定的實現(xiàn)原理
本篇文章主要介紹了淺談vue中數(shù)據(jù)雙向綁定的實現(xiàn)原理 ,主要使用v-model這個數(shù)據(jù)雙向綁定,有興趣的可以了解一下2017-09-09
基于Vue實現(xiàn)文件上傳的幾種實現(xiàn)方式
文件上傳是web開發(fā)中一個常見的需求,Vue.js作為一款流行的前端框架,也提供了方便的方法來實現(xiàn)文件上傳功能,下面這篇文章主要給大家介紹了關(guān)于基于Vue實現(xiàn)文件上傳的幾種實現(xiàn)方式,需要的朋友可以參考下2024-03-03

