vue-cli 4 安装与 新建项目 路由
2024-10-21 03:40:44
环境:
windows:
vue-cli:
编辑器: vsCode
npm: 6.11. #去nodejs网安装https://npm.taobao.org/mirrors/node/v12.12.0/node-v12.12.0-x64.msi
1.安装 :
>npm install -g @vue/cli
# 查看版本
PS D:\vue\project-> vue -V
@vue/cli 4.0.
2.创建项目:
添加淘宝镜像:
npm install -g cnpm --registry=https://registry.npm.taobao.org
创建项目
vue init webpack my-project
或者
vue create project- #这里可以上下选择, 我们选 手动
Vue CLI v4.0.4
? Please pick a preset:
default (babel, eslint)
> Manually select features # 然后根据自己的需求选组件
Vue CLI v4.0.4
? Please pick a preset: Manually select features
? Check the features needed for your project:
(*) Babel
( ) TypeScript
( ) Progressive Web App (PWA) Support
(*) Router
(*) Vuex
(*) CSS Pre-processors
>(*) Linter / Formatter
( ) Unit Testing
( ) E2E Testing
3.创建路由
3.1 在{项目路径}/src/router/index.js中添加一路由
3.2 在App.vue 中添加 <router-link to="/demo1">Demo1</router-link>
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link> |
<router-link to="/demo1">Demo1</router-link>
</div>
<router-view/>
</div>
</template> <style lang="less">
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
} #nav {
padding: 30px; a {
font-weight: bold;
color: #2c3e50; &.router-link-exact-active {
color: #42b983;
}
}
}
</style>
3.3 创建 Demo1.vue
<template>
<div class="test">
<h1>This is an Demo1 page</h1> </div> </template> <script>
</script> <style lang=""> </style>
3.4 运行项目
>npm run serve DONE Compiled successfully in 3656ms :: App running at:
- Local: http://localhost:8080/
- Network: http://192.168.1.105:8080/ Note that the development build is not optimized.
To create a production build, run npm run build.
3.5 测试,访问 http://localhost:8080/demo1
最新文章
- java关键字extends(继承)、Supe(父类引用空间)、 This(方法调用者对象)、Instanceof(实例类型-判断对象是否属于某个类)、final(最终)、abstract(抽象) 、interface(接口)0
- 用c#开发的一款webservice调用小工具,方便测试
- <;context:component-scan>;使用说明
- python 脚本
- 各种语言HMAC SHA256实现
- nginx配置错误
- 数字图像处理(MATLAB版)学习笔记(2)——第2章 灰度变换与空间滤波
- Ruby中文乱码问题
- tomcat是什么?Tomcat 下载、安装、配置图文教程
- 傻瓜式搭建私人网络硬盘——owncloud安装指南
- [转]浅谈Normalize.css
- jquery中innerwidth,outerwidth,outerwidth和width的区别
- Android 學習之旅!(2)
- jmeter之beanshell取出需要参数,传递给下个请求
- 比较两种方式的form请求提交
- js基础-运算符
- 【转】Java学习---Java的锁和Mysql的锁机制
- 问题解决:IDEA右键选择new新文件的时候没有JSP文件选项解决
- Life is in the little things --- Spreading wildly on Facebook
- 【CS231N】2、多类SVM
热门文章
- ASP.NET Core开发者指南(转发)
- Java界面程序实现图片的放大缩小
- 使用gimp画线、矩形、圆等
- DES加密解密工具
- 【Web】jquery合并单元格
- 06 vue router(一)
- php使用装饰模式无侵入式加缓存
- 0-1 RSS订阅
- 解决pip安装第三方包编码错误:UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte....
- meta viewport移动端自适应