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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值