構建一個新項目
npm install -g create-vite-app
create-vite-app my-vue3-vite
cd my-vue3-vite
npm install
npm run dev
啟動之后:
css預處理器需要放在package.json的devDependencies中壁公;
"devDependencies": {
"less": "^3.12.2",
"less-loader": "^7.0.1",
"vite": "^1.0.0-rc.1",
"@vue/compiler-sfc": "^3.0.0-rc.1"
}
路由配置悴晰,新建一個文件夾router壮啊,新建index.js文件
index.js文件內(nèi)容
import {
createRouter,
createWebHistory
} from 'vue-router'
import Login from '../page/index.vue'
const routerHistory = createWebHistory()
const router = createRouter({
history: routerHistory,
routes: [{
path: '',
name: 'login',
component: Login
}],
})
export default router