🎉 getters使用
This commit is contained in:
parent
eb49928833
commit
b878032303
|
@ -5,6 +5,11 @@ Vue.use(Vuex);
|
|||
const count = {
|
||||
namespaced: true,
|
||||
state: { num: 1, sum: 0 },
|
||||
getters: {
|
||||
bigSum(state) {
|
||||
return state.sum * 10;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
// 奇数相加
|
||||
incrementOdd(context) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<div>
|
||||
<h1>当前求和为:{{ $store.state.count.sum }}</h1>
|
||||
<h1>当前求和为:{{ $store.getters["count/bigSum"] }}</h1>
|
||||
<select v-model.number="$store.state.count.num">
|
||||
<option :value="1">1</option>
|
||||
<option :value="2">2</option>
|
||||
|
|
Loading…
Reference in New Issue