视频参考链接
npm init vite@latest easyblog-front-admin
cd easyblog-front-admin
npm install
npm run dev
import { createRouter, createWebHistory } from 'vue-router'
const routes = [
{}
];
//这里不是通过new来创建,通过createRouter 方法创建,使用的模式不是通过mode来定义
const router = createRouter({
routes,
history: createWebHistory(),
})
export default router
{
"Print to console": {
"prefix": "vue3",
"body": [
"",
" ",
"",
"",
"",
"",
"",
],
"description": "Log output to console"
}
}
vue-html.json
{
"el-form模板": {
"prefix": "el-form",
"description": "创建el-form",
"body": [
",
" :model=\"formData\"",
" :rules=\"rules\"",
" ref=\"formDataRef\"",
" label-width=\"80px\"",
">",
"",
" " ,
" ",
" ",
"",
" ,
" label=\"\"",
" prop=\"\"",
" clearable",
" placeholder=\"提示信息\"",
" type=\"textarea\"",
" :rows=\"5\"",
" :maxlength=\"150\"",
" resize=\"none\"",
" show-word-limit",
" v-model=\"formData.\"",
" >",
" ",
"",
" " ,
" " ,
" 显示信息 ",
" 显示信息 ",
" ",
" ",
"",
" " ,
" " ,
" ",
" ",
" ",
" ",
" ",
]
},
"el-input模板": {
"prefix": "el-input",
"description": "创建el-input",
"body": [
"",
" " ,
" ",
" ",
]
},
"el-textarea模板": {
"prefix": "el-textarea",
"description": "创建el-input",
"body": [
"",
",
" label=\"\"",
" prop=\"\"",
" clearable",
" placeholder=\"提示信息\"",
" type=\"textarea\"",
" :rows=\"5\"",
" :maxlength=\"150\"",
" resize=\"none\"",
" show-word-limit",
" v-model=\"formData.\"",
" >",
" ",
]
},
"el-radio模板": {
"prefix": "el-radio",
"description": "创建el-radio",
"body": [
"",
" " ,
" " ,
" 显示信息 ",
" 显示信息 ",
" ",
" ",
]
},
"el-select模板": {
"prefix": "el-select",
"description": "创建el-select模板",
"body": [
"",
" " ,
" " ,
" ",
" ",
" ",
" ",
]
},
}
javascript.lson
{
"dialog弹窗配置": {
"prefix": "dialogConfig",
"description": "弹窗config配置",
"body": [
"const dialogConfig = reactive({",
" show: false,",
" title: \"标题\",",
" buttons: [",
" {",
" type: \"danger\",",
" text: \"确定\",",
" click: (e) => {",
" submitForm();",
" },",
" },",
" ],",
"});"
]
},
"watch使用": {
"prefix": "watch",
"description": "快速实现watch",
"body": [
"watch(() => (newVal, oldVal) => {}, { immediate: true, deep: true });",
]
}
}
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path"
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
server: {
hmr: true,
port: 3001,
proxy: {
'/api': {
target: "http://localhost:8081/", // 目标代理接口地址
secure: false,
changeOrigin: true, // 开启代理,在本地创建一个虚拟服务端
pathRewrite: {
'^/api': '/api',
},
},
},
},
resolve: {
// 配置路径别名
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})
还需要安装path包
npm install path --save
项目的初始搭建就完成啦!整个过程还算顺利!