# Ep17#05 - Lấy dữ liệu với getter trong vuex (ok)

<figure><img src="/files/Rrf47ND4ELNjZZ2UA4WF" alt=""><figcaption></figcaption></figure>

C:\Users\Administrator\Desktop\imoney\src\components\AppResult.vue

```javascript
<template>
  <div>
   {{ $store.state.result }}
  </div>
</template>
<script>
export default {
  name: 'AppCount'
}
</script>
```

C:\Users\Administrator\Desktop\imoney\src\App.vue

```javascript
<template>
  <div id="app">
    <img alt="Vue logo" src="./assets/logo.png">
    <AppResult />
    <br/>
    <OtherResult />
    <br/>
    <app-count />
  </div>
</template>
<script>
import AppCount from './components/AppCount.vue'
import AppResult from './components/AppResult.vue'
import OtherResult from './components/OtherResult.vue'
export default {
  name: 'App',
  components: {
    AppResult,
    AppCount,
    OtherResult
  }
}
</script>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

```

C:\Users\Administrator\Desktop\imoney\src\components\OtherResult.vue

```javascript
<template>
  <div>
   {{ result }}
  </div>
</template>
<script>
export default {
  name: 'AppCount',
  computed: {
    result() {
      return this.$store.getters.testResult
    }
  }
}
</script>
```

C:\Users\Administrator\Desktop\imoney\src\components\AppCount.vue

```javascript
<template>
  <div>
    <button @click="increment">Increment</button>
    <button @click="decrement">Decrement</button>
  </div>
</template>
<script>
export default {
  name: 'AppCount',
  methods: {
    increment() {
      this.$store.state.result++
    },
    decrement() {
      this.$store.state.result--
    }
  }
}
</script>

```

C:\Users\Administrator\Desktop\imoney\src\store.js

```javascript
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export const store = new Vuex.Store({
  state: {
    result: 0
  },
  getters: {
    testResult: state => {
      return state.result * 10;
    }
  }
})
```

C:\Users\Administrator\Desktop\imoney\src\main.js

```javascript
import Vue from 'vue'
import App from './App.vue'
import {store} from './store.js'
Vue.config.productionTip = false
new Vue({
  store,
  render: h => h(App),
}).$mount('#app')
```

C:\Users\Administrator\Desktop\imoney\package.json

```javascript
{
  "name": "Aaaaaaaa",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.8.3",
    "vue": "^2.6.14",
    "vue-router": "3.6.5",
    "vuex": "2.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.16",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "vue-template-compiler": "^2.6.14"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "@babel/eslint-parser"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnmagento.gitbook.io/vuejs/ep17-05-lay-du-lieu-voi-getter-trong-vuex-ok.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
