Vue.js(二)安装与部署

三种方法

第一种

1、打开这个网址
https://cn.vuejs.org/v2/guide/installation.html
2、点击这个下载
在这里插入图片描述3、在页面中把vue.js引入项目,在项目中引用

 <script src="vue.js" type="text/javascript" charset="UTF-8"></script>

如果你的页面按F12键出现以下的情况说明已经成功
在这里插入图片描述

第二种

直接在页面中引用这个就行了

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

第三种

NPM 方法

由于 npm 安装速度慢,本教程使用了淘宝的镜像及其命令 cnpm,安装使用介绍参照:使用淘宝 NPM 镜像。

npm 版本需要大于 3.0,如果低于此版本需要升级它:

查看版本

$ npm -v
2.3.0

#升级 npm
cnpm install npm -g

升级或安装 cnpm

npm install cnpm -g

在用 Vue.js 构建大型应用时推荐使用 NPM 安装:

最新稳定版

$ cnpm install vue

扫描二维码关注公众号,回复: 8755648 查看本文章

命令行工具

Vue.js 提供一个官方命令行工具,可用于快速搭建大型单页应用。

全局安装 vue-cli

$ cnpm install --global vue-cli

创建一个基于 webpack 模板的新项目

$ vue init webpack my-project

这里需要进行一些配置,默认回车即可

This will install Vue 2.x version of the template.

For Vue 1.x use: vue init webpack#1.0 my-project

? Project name my-project
? Project description A Vue.js project
? Author runoob [email protected]
? Vue build standalone
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? Yes

vue-cli · Generated “my-project”.

To get started:

 cd my-project
 npm install
 npm run dev

Documentation can be found at https://vuejs-templates.github.io/webpack

进入项目,安装并运行:

$ cd my-project
$ cnpm install
$ cnpm run dev
DONE Compiled successfully in 4388ms

Listening at http://localhost:8080

成功执行以上命令后访问 http://localhost:8080/,输出结果如下所示:
在这里插入图片描述

发布了45 篇原创文章 · 获赞 7 · 访问量 906

猜你喜欢

转载自blog.csdn.net/qq_42222342/article/details/104034312