推荐一个 vue3 全家桶 ts vite2 element-凯发k8官方网
凯发k8官方网
收集整理的这篇文章主要介绍了
推荐一个 vue3 全家桶 ts vite2 element-plus 的网站实战项目
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
五一期间,花了 3 天时间,边学 vue3 和 vite2,边重构自己的项目,终于都用 vue3 typescript vite2 vuex4 vue-router4 element-plus 重构完啦!
终于完成一项心心念念的 2021 年度目标了 ✌️
项目地址:
https://github.com/biaochenxuying/blog-vue-typescript
效果
效果图:
pc 端
移动端
完整效果请看:
https://biaochenxuying.cn
功能
已经完成功能
[x] 登录
[x] 注册
[x] 文章列表
[x] 文章归档
[x] 标签
[x] 关于
[x] 点赞与评论
[x] 留言
[x] 历程
[x] 文章详情(支持代码语法高亮)
[x] 文章详情目录
[x] 移动端适配
[x] github 授权登录
前端主要技术
所有技术都是当前最新的。
vue:^3.0.5
typescript : ^4.1.3
element-plus: ^1.0.2-beta.41
vue-router : ^4.0.6
vite: ^2.2.3
vuex: ^4.0.0
axios: ^0.21.1
highlight.js: ^10.7.2
marked:^2.0.3
1. 初化化项目
用 vite-app 创建项目
yarn create vite-app然后按照提示操作即可!
进入项目,安装依赖
cd运行项目
yarn dev打开浏览器 http://localhost:3000 查看
2. 引入 typescript
在创建项目的时候可以 typescript 的,如果你选择了 typescript ,可以忽略第 2 个步骤。
加入 ts 依赖
yarn add --dev typescript在 项目根目录下创建 typescript 的配置文件 tsconfig.json
{"compileroptions": {// 允许从没有设置默认导出的模块中默认导入。这并不影响代码的输出,仅为了类型检查。"allowsyntheticdefaultimports": true,// 解析非相对模块名的基准目录"baseurl": ".","esmoduleinterop": true,// 从 tslib 导入辅助工具函数(比如 __extends, __rest等)"importhelpers": true,// 指定生成哪个模块系统代码"module": "esnext",// 决定如何处理模块。"moduleresolution": "node",// 启用所有严格类型检查选项。// 启用 --strict相当于启用 --noimplicitany, --noimplicitthis, --alwaysstrict, // --strictnullchecks和 --strictfunctiontypes和--strictpropertyinitialization。"strict": true,// 生成相应的 .map文件。"sourcemap": true,// 忽略所有的声明文件( *.d.ts)的类型检查。"skiplibcheck": true,// 指定ecmascript目标版本 "target": "esnext",// 要包含的类型声明文件名列表"types": [],"isolatedmodules": true,// 模块名到基于 baseurl的路径映射的列表。"paths": {"@/*": ["src/*"]},// 编译过程中需要引入的库文件的列表。"lib": ["esnext","dom","dom.iterable","scripthost"]},"include": ["src/**/*.ts","src/**/*.tsx","src/**/*.vue","tests/**/*.ts","tests/**/*.tsx"],"exclude": ["node_modules"] }在 src 目录下新加 shim.d.ts 文件
/* eslint-disable */ import type { definecomponent } from 'vue'declare module '*.vue' {const component: definecomponent<{}, {}, any>export default component }把 main.js 修改成 main.ts
在根目录,打开 index.html
- 上一篇: 前端月趋势榜:4 月最热门的 20 个前
- 下一篇: 推荐 12 个提升程序员软技能与效率的必