CLI

cli是vue提供的一个用来快速构建项目环境的一个工具,底层使用的是webpack

cli的安装 npm/cnpm/yarn 都可以使用

使用国内镜像加速npm和yarn
npm config set registry=https://registry.npm.taobao.org
yarn config set registry https://registry.npm.taobao.org
下载cnpm:npm install -g cnpm registry=https://registry.npm.taobao.org

创建项目

cli3版本创建

        命令创建 【 推荐 】  vue create 项目名称

  图形界面创建  vue ui

cli2版本创建

  1. 标准版  vue init webpack 项目名称
  2. 简易版  vue init webpack-simple 项目名称
异步组件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <div id="app"> <Hello></Hello> </div> </body> <script src="../../lib/vue.js"></script> <script> Vue.component('Hello', function (resolve, reject) { setTimeout(function () { resolve({ template: '<div>I am async!</div>' }) }, 1000) }) new Vue({ el: '#app' }) </script> </html>


posted @ 2019-08-02 16:58  everjin  阅读(455)  评论(0编辑  收藏  举报