首先安装node,git再进行下面的操作
1.安装vue-cli
npm install vue-cli -g
2.初始化项目
vue init webpack pctext
3.安装依赖
npm install
4.安装淘宝镜像cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
但是这里我们建议用alias 安装因为npm安装的版本号和cnpm不一致
alias cnpm=“npm --registry=https://registry.npm.taobao.org
–cache=KaTeX parse error: Expected 'EOF', got '\ ' at position 23: …pm/.cache/cnpm \̲ ̲--disturl=https…HOME/.cnpmrc”
5.安装路由
npm install vue-router --save
router
新建项目的时候就会有默认的把你页面改成这样就行了
在src中router目录下index.js中引入vue-router
import Routerfrom ‘vue-router’
Vue.use(Router);//注册router
①配置路由(我们提前新建两个页面来协作完成路由)
export default new Router({
mode: ‘history’,
routes: [
{
path: ‘/’,
name: ‘Apple’,
component: Apple
},
{
path: ‘/banan’,
name: ‘Banan’,
component: Banan
}
]
})
VUEX
安装vuex
npm install vuex --save
action—>mutations—>state—>vue components
action 异步操作
mutations 同步操作
status 状态