当前位置: 首页 > news >正文

vue create创建 Vue-router 工程

vue create创建 Vue-router 工程

参考
创建vue项目的两种方式:vue-create与vite
https://www.cnblogs.com/reverse-x/p/16806534.html

Vue2 脚手架 创建工程 测试程序
https://blog.csdn.net/wowocpp/article/details/146590400

在 上面的基础上
cd .\vue2-demo\

vue create demo2

在这里插入图片描述

Vue CLI v5.0.8
? Please pick a preset:
  Default ([Vue 3] babel, eslint) 
  Default ([Vue 2] babel, eslint) 
> Manually select features  

选择
Manually select features

选择

Vue CLI v5.0.8
? Please pick a preset: Manually select features
? Check the features needed for your project: (Press <space> to select, <a> to toggle all, <i> to invert
selection, and <enter> to proceed)
>(*) Babel
 ( ) TypeScript
 ( ) Progressive Web App (PWA) Support
 (*) Router
 ( ) Vuex
 (*) CSS Pre-processors
 ( ) Linter / Formatter
 ( ) Unit Testing
 ( ) E2E Testing

Linter / Formatter 是干嘛的

? Check the features needed for your project: Babel, Router, CSS Pre-processors      
? Choose a version of Vue.js that you want to start the project with 
  3.x
> 2.x

选择Vue2

? Check the features needed for your project: Babel, Router, CSS Pre-processors      
? Choose a version of Vue.js that you want to start the project with 2.x
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) n

如果选择了vue-router的话会弹出一个选项,问你是否需要安装历史模式的路由,选N 因为要用哈希模式的路由
选择Css书写格式

? Check the features needed for your project: Babel, Router, CSS Pre-processors      
? Choose a version of Vue.js that you want to start the project with 2.x
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): 
  Sass/SCSS (with dart-sass)
> Less
  Stylus

config

? Check the features needed for your project: Babel, Router, CSS Pre-processors      
? Choose a version of Vue.js that you want to start the project with 2.x
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Less
? Where do you prefer placing config for Babel, ESLint, etc.? 
  In dedicated config files
> In package.json

config

? Save this as a preset for future projects? (y/N) N

11

 cd demo2
 npm run serve
Home页面

在这里插入图片描述

About 页面

在这里插入图片描述
在这里插入图片描述

main.js

在这里插入图片描述

App.vue

在这里插入图片描述

添加一个 Hi.vue

<template>
  <div id="hi">
    <h1>Hi.vue组件</h1>
  </div>
</template>
<script>
export default {
  name: "Hi",
};
</script>
<style scoped>
</style>

router/index.js

import Hi from '../components/Hi'
 {
    path: '/hi',
    name: 'Hi',
    component: Hi
  }

App.vue

<template>
  <div id="app">
    <nav>
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>|
      <router-link to="/hi">Hi</router-link>
    </nav>
    <router-view />
  </div>
</template>

相关文章:

  • AI赋能SEO关键词智能优化
  • VMware虚拟机 ubuntu22.04无法与共享粘贴板和拖拽文件的解决方案
  • 细说AGV叉车的导航,如何精准定位并选取最优路径?
  • NX二次开发刻字功能——预览功能
  • 盈亏平衡分析
  • SWEET-RL:基于训练时信息的多轮LLM代理强化学习框架
  • 计算机二级WPS Office第十二套WPS演示
  • LIMS系统如何构筑染料质检的防线 质检LIMS系统在染料生产企业的应用
  • 在学校图书馆知识库中进行论文检索报告生成
  • 【Kafka】深入探讨 Kafka 如何保证一致性
  • 《白帽子讲 Web 安全》之服务端请求伪造(SSRF)深度剖析:从攻击到防御
  • 【云成本优化案例】K8s计费探针让跨境电商企业节省30%云预算
  • 视频编码器的抉择:x264、x265、libaom、vvenc 对比测试实验
  • 用Python插入Excel表格到Word文档
  • 【linux】常用命令
  • 一次与chatgpt关于VO的深入讨论。
  • 3. 无重复字符的最长子串
  • DeepSeek-V3新版本DeepSeek-V3-0324
  • Android 中隐藏标题栏和状态栏的方法
  • QCW模式:准连续波驱动在VCSEL激光器中的技术解析与应用价值
  • 小雨伞保险经纪母公司手回集团通过港交所聆讯
  • 美国将与阿联酋合作建立海外最大的人工智能数据中心
  • 上海率先推进生物制品分段生产试点,这款国产1类创新药获批上市
  • 证监会发布《上市公司募集资金监管规则》,6月15日起施行
  • 商务部:中方敦促美方尽快停止232关税措施
  • 玉渊谭天丨卢拉谈美国降低对华关税:中国的行动捍卫了主权