安装vite

使用npm

npm create vite@latest

使用yarn

yarn create vite

使用pnpm

pnpm create vite

还有一些选择配置比如使用那种框架,我使用的vue,还有使用JavaScript等以及项目的命名

还可以通过附加的命令行选项直接指定项目名称和想要使用的模板。例如,要构建一个 Vite + Vue 项目,运行:

# npm 6.x
npm create vite@latest my-vue-app --template vue # npm 7+, extra double-dash is needed:
npm create vite@latest my-vue-app -- --template vue # yarn
yarn create vite my-vue-app --template vue # pnpm
pnpm create vite my-vue-app --template vue

查看 create-vite 以获取每个模板的更多细节:vanillavanilla-tsvuevue-tsreactreact-tspreactpreact-tslitlit-tssveltesvelte-ts

安装vue-router路由

1.先安装路由

使用npm:安装最新版的路由到开发环境中

npm i vue-router -D

使用yarn:意思是安装4版本的路由

yarn add vue-router@4

2.创建index.js文件

在src目录下新建router目录,并新建index.js文件

//1.从VueRouter中导入需要的函数模块
import {createRouter, createWebHashHistory } from 'vue-router'
// 2.导入 HelloWorld.vue 组件
const routes = [
{ path: '/', component: () => import('../components/HelloWorld.vue')}
] // 3. 创建路由实例并传递 `routes` 配置
// 你可以在这里输入更多的配置,但我们在这里
// 暂时保持简单
const router = createRouter({
// 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
history: createWebHashHistory(),
routes, // `routes: routes` 的缩写
}) //导出router
export default router

3.接着还要到main.js文件中把router挂载上去

import { createApp } from 'vue';
import App from './App.vue';
import router from './router/index'; //导入router配置文件 const app = createApp(App);
app.use(router); //挂载router
app.mount('#app');

4.使用的话记得要给路由搞个出口

app.vue文件中

<template>
<router-view /> //使用的router-view
</template>

安装状态管理工具

额等我有空在写这个部分,有上面的两个部分简单学习使用能搭建页面出来正常使用了

最新文章

  1. JSONKit在项目中使用设置(ARC与方法更新)
  2. 提权GrantPrivilege
  3. 【mysql】数据库使用的一些规范
  4. Sqlserver自定义函数Function
  5. Python 基礎 - while流程判斷
  6. ASP.NET MVC学习之过滤器篇(2)
  7. 【JS复习笔记】06 方法
  8. 表结构导出到excel中
  9. @Autowired获取配置文件中被注入实例的两种方式
  10. redis 用setbit(bitmap)统计活跃用户
  11. soket客户端程序(一)
  12. Dubbo亮点总结
  13. openstack中glance组件images的全部python API 汇总
  14. XMAL 中x名称控件的Auttribute
  15. 用PHPMailer在本地win环境,可以接收到邮件和附件,但在linux环境只能接收邮件信息接不到附件,是我的路
  16. PDO学习
  17. Mybatis接口编程原理分析(二)
  18. RNA-seq标准化
  19. rad 10.2
  20. 【Python基础】安装python第三方库

热门文章

  1. ELK日志报警插件ElastAlert并配置钉钉报警
  2. ProxySQL 匹配规则
  3. Linux下从零开始创建lvm虚拟磁盘阵列+脚本化解决方案
  4. 4.第三篇 PKI基础概念、cfssl工具介绍及kubernetes中证书
  5. My life of Honker Security Commando
  6. 6_SSM
  7. FEX-EMU Wine踩坑记录
  8. golang channel底层结构和实现
  9. 移动端Vant组件库REM适配
  10. 手把手教你使用LabVIEW OpenCV dnn实现物体识别(Object Detection)含源码