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

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>

http://www.kler.cn/a/614055.html

相关文章:

  • 搭建前端环境和后端环境
  • 1.1 计算机网络的概念
  • 硬件面试问题
  • 如何将Java一个微服务框架如何集成一个单体springboot应用?
  • STM32F103_LL库+寄存器学习笔记06 - 梳理串口与串行发送“Hello,World“
  • uv 命令用conda命令解释
  • 【redis】数据类型之Stream
  • 《鸿蒙携手AI:解锁智慧出行底层逻辑》
  • 亚马逊玩具品类技术驱动型选品策略:从趋势洞察到合规基建
  • TensorFlow之常量的使用1
  • CentOS 7 换源
  • 怎么使用pm2启动和暂停后端程序(后端架构nodejs+koa)
  • 前端 技术栈
  • spring-security原理与应用系列:核心过滤器
  • ARCGIS PRO SDK VB2022 图层要素类类型判断
  • WPF ContentTemplate
  • JavaScript网页设计高级案例:构建交互式图片画廊
  • 阀门流量控制系统MATLAB仿真PID
  • 上海做一场公关活动,有哪些媒体可以邀请?
  • 如何让 history 记录命令执行时间?Linux/macOS 终端时间戳设置指南