feat: 添加路由
This commit is contained in:
15
src/main.ts
15
src/main.ts
@@ -1,6 +1,8 @@
|
||||
import { createApp } from 'vue';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { createMemoryHistory, createRouter } from 'vue-router';
|
||||
import App from './App.vue';
|
||||
import HelloWorld from './components/HelloWorld.vue';
|
||||
import './style.css';
|
||||
const i18n = createI18n({
|
||||
locale: 'zh',
|
||||
@@ -18,7 +20,20 @@ const i18n = createI18n({
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const routes = [
|
||||
{ path: '/', component: App },
|
||||
{ path: '/about', component: HelloWorld },
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes,
|
||||
});
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(i18n);
|
||||
|
||||
app.use(router);
|
||||
|
||||
app.mount('#app');
|
||||
|
||||
Reference in New Issue
Block a user