vue
来源:互联网 发布:短信轰炸源码 编辑:程序博客网 时间:2024/06/06 00:59
vue init simple vue-simple-demo
vue init simple#1.0 vue-simple-demo
vue init webpack#1.0 vue-webpack-demo
npm install
npm run dev
vue init simulatedgreg/electron-vue#1.0 my-project
# 安装 vue-cli 和 脚手架样板代码npm install -g vue-clivue init simulatedgreg/electron-vue my-project# 安装依赖并运行你的程序cd my-projectyarn # 或者 npm installyarn run dev # 或者 npm run dev
import Vue from 'vue'import Vuex from 'vuex'Vue.use(Vuex)const state = { count: 4}const mutations = { jia (state) { state.count++ }, jian (state) { state.count-- }}export default new Vuex.Store({ state, mutations})
import store from "./score"
computed:mapState({ count:state=>state.count+2})
computed:mapState([// 映射 this.count 为 store.state.count'count'])
commit触发
computed:mapState([// 映射 this.count 为 store.state.count'count'])
commit('xxx',参数,参数)
commit('xxx',{a:"xxx})
xxx(state,x){
x.a
}
methods:mapMutations(['jia','jian'])
import { mapState,mapMutations } from "vuex"
mapGetters
getterscomputed:{ ...mapState([ 'count' ]), ...mapGetters([ "count" ])}
jianp(commit){ commit('jian')}
...mapActions:{
jianp:'jianp'
}