~~~
<template>
<div>
<p>click {{count}} times, count is {{evenOrOdd}}</p>
<button @click="increment">+</button>
<button @click="decrement">-</button>
<button @click="incrementIfOdd">increment if odd</button>
<button @click="incrementAsync">increment async</button>
</div>
</template>
<script>
import {mapState, mapGetters, mapActions} from 'vuex'
export default {
name: 'Hello',
mounted () {
console.log(this.$store)
},
//方式1
// computed: {
// count () {
// return this.$store.state.count
// },
// evenOrOdd () {
// return this.$store.getters.evenOrOdd
// }
// },
// methods: {
// increment () {
// this.$store.dispatch('increment')
// },
// decrement () {
// this.$store.dispatch('decrement')
// },
// incrementIfOdd () {
// this.$store.dispatch('incrementIfOdd')
// },
// incrementAsync () {
// this.$store.dispatch('incrementAsync')
// }
//}
//方式2
computed: {
...mapState(['count']),
...mapGetters(['evenOrOdd'])
},
methods: {
...mapActions(['increment', 'decrement', 'incrementIfOdd', 'incrementAsync'])
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
~~~
- 開發工具
- VsCode
- 常用插件
- Html5
- 標簽
- video
- form
- 讀取文件
- 地理位置
- canvas
- 本地存儲
- localStorage
- sessionStorage
- 網絡狀態
- Css3
- 背景
- 邊框
- 邊框圖片
- 文字陰影
- 漸變
- Js
- ES6
- 常量和變量
- 模板字符串
- 箭頭函數
- 解構賦值
- Spread Operator
- import export
- Promise
- 打包
- webpack
- 安裝
- 為什么要打包
- 核心概念
- 熱更新
- 入門例子
- js打包
- css打包
- vue
- 簡介
- Vue-cli
- 搭建
- 打包發布
- eslint
- Mint-ui
- Vuex
- 狀態管理模式
- 使用
- main.js
- store
- component
- Mockjs
- 簡介
- EasyMock