在对vue进行路由配置的时候遇到了页面是空白的问题,用两个最简单的页面配置完也是同样的问题,渲染不出来东西,下面是我的相关代码,也没有任何的报错
index.js
import { createRouter, createWebHistory } from "vue-router";
// 引入
import About from "../components/AboutView.vue";
import Home from "../components/HomeView.vue";
// 路由信息
let routes = [
{
path: "/",
name: 'home',
component: Home,
},
{
path: "/about",
name: 'about',
component: About,
},
];
// 路由器
const router = createRouter({
history: createWebHistory(), // HTML5模式
routes,
});
export default router;
main.js
import { createApp } from 'vue';
import App from './App.vue';
// 引入插件
import router from './router';
// 安装router插件
createApp(App).use(router).mount('#app')
App.vue
<template>
<div>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link><br />
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'App',
data(){
return {
message:"学习Vue"
}
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
想要成功渲染