3 Star 16 Fork 4

卡卡罗特 / 基于vite+vue3+vant4的移动端H5应用

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Vue 3 + TypeScript + Vite + pinia + Vant4 : SPA

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

本多页应用使用到的技术:

  • vite 4.x:vue作者研发并推荐的开箱即用构建工具,同时为项目提供超快热重启开发环境;相对于webpack,Vite更加轻量,并且构建速度足够快。
  • typescript:javascript的超集,es-next一指努力追求的最终形态语法标准。
  • vue 3.x:vue3最新版本。
  • vue-router 4.x:vue3下最新的路由。
  • pinia 2.x:轻量级状态管理库,vue官方认证取代vuex:完整的 TypeScript 支持,更加轻量体积。
  • vant 4.x:有赞的轻量、可定制的移动端组件库最新版。
  • Nodejs 版本要求:16+

在main.ts中,手动于入口处引用vant中以函数形式提供的组件的样式,根据项目实际可注释掉部分全局引入

  • import 'vant/es/toast/style' //toast
  • import 'vant/es/dialog/style' //dialog
  • import 'vant/es/notify/style' //notify
  • import 'vant/es/image-preview/style' //imagePreview

更换颜色样式,一共两处地方,直接修改颜色即可

  • src/assets/global.css: 修改自定义变量、vant4指定变量的值,即可实现全局修改
  • src/assets/scss/theme.scss: 修改定义全局的scss使用的$样式变量,以便让系统同时支持var(--*)和$**两种写法

注意

每一个路由views的模板template,都必须放在一个根节点内,否则将影响路由切换动画效果

读取/写入登录token方法:

src/store/user.ts中的getToken、setToken、resetToken ,内部实现可根据实际项目改写

本项目中所有typescript数据结构定义,均保存在:

src/types/index.ts

Recommended IDE Setup

Type Support For .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.
MIT License Copyright (c) 2023 卡卡罗特 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于vite+vue3+vant4的移动端H5应用 展开 收起
TypeScript 等 5 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/foolegg126/weg-vant-h5.git
git@gitee.com:foolegg126/weg-vant-h5.git
foolegg126
weg-vant-h5
基于vite+vue3+vant4的移动端H5应用
master

搜索帮助