Vue的安装与使用

1.为方便安装,先安装cnpm;

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm -v可查看版本

2.安装webpack3.0.因为最新4.0的需要node14版本以上,而win7并不支持.
cnpm install -g webpack@3.0

3.再安装vue-cli
cnpm install --global vue-cli
查看版本 vue -V 我当前是2.96的版本.这是刚安装的那些模板

上面这种安装出来一般是vue2.9的版本.如果要安装3.0或以上的版本按下面的来
npm install -g @vue/cli@3.*
npm install -g @vue/cli-init
然后再去创建VUE项目
4.创建VUE项目.
  vue init webpack-simple 项目名
  cd 项目名
  npm install
  npm run dev
上面这样创建出来是低于3.0的。如果3.0的按下面这样创建
vue create 项目名
cd 项目名
npm run server
php请求的跨域设置
header('Access-Control-Allow-Origin: *'); 
header('Access-Control-Allow-Credentials: true'); 
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); 
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); 

  

原文地址:https://www.cnblogs.com/bing2017/p/13266177.html