路由篇
router/index.ts同ES6的router/index.js写法相同
import { createRouter, createWebHashHistory } from \"vue-router\"
import Home from \'../views/Home.vue\'
const routes = [
{
path: \'/\',
name: \'Home\',
component: Home
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
})
export default router
但main.ts中不同
import { createApp } from \'vue\'
import App from \'./App.vue\'
import router from \'./router/index\' // ES6中是import router from \'./router\'
import ElementPlus from \'element-plus\'
import \'element-plus/dist/index.css\'
const app = createApp(App)
app.use(router).use(ElementPlus).mount(\'#app\')