vue3写法
main.js
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
createApp(App).use(router).mount('#app')
router/index.js
import { createRouter,createWebHistory } from "vue-router";
import HelloWorld from '../components/HelloWorld.vue';
const router = createRouter({
history:createWebHistory(),
routes:[
{
path:'/',
component:HelloWorld,
}
]
})
export default router;
hellow.vue
<template>
<div class="hello">
我是第一个路由组件
</div>
</template>
<script>
export default {
name: 'HelloWorld'
}
</script>
<style scoped>
</style>