Vue安装

作者: xiaolizhenzhen | 来源:发表于2018-05-30 16:09 被阅读0次

    vue安装

    1.独立版本

    在 Vue.js 的官网上直接下载 vue.min.js 并用 <script> 标签引入。

    2.CDN托管

    以下推荐国外比较稳定的两个 CDN,国内还没发现哪一家比较好,目前还是建议下载到本地。

    BootCDN(国内) : https://cdn.bootcss.com/vue/2.2.2/vue.min.js

    unpkg:https://unpkg.com/vue/dist/vue.js
    会保持和 npm 发布的最新的版本一致。

    cdnjs : https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.8/vue.min.js

    3.NPM 方法

    由于 npm 安装速度慢,可使用淘宝的镜像及其命令 cnpm
    npm 版本需要大于 3.0,如果低于此版本需要升级.

    # 查看版本
    $ npm -v
    
    
    # 使用淘宝定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm
    $ npm install -g cnpm --registry=https://registry.npm.taobao.org
    
    
    #升级 npm
    cnpm install npm -g
    
    # 用 Vue.js 构建大型应用时推荐使用 NPM 安装
    # 最新稳定版
    $ cnpm install vue
    
    
    命令行工具

    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 <test@runoob.com>
    ? 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
    

    相关文章

      网友评论

          本文标题:Vue安装

          本文链接:https://www.haomeiwen.com/subject/jiqxsftx.html