Install:

npm install -g vue-cli

Init project:

vue init nuxt/starter .

Run:

npm run dev

Create a index.js file inside store folder:

import Vuex from 'vuex'

const store = () => new Vuex.Store({
state: {
counter: 0
}
}) export default store

Display the counter inside pages/index.vue:

<template>
<div>
Counter: {{counter}}
</div>
</template> <script>
import { mapState } from 'vuex' export default {
computed: mapState({
counter: (state) => state.counter
})
}
</script>

mapState: return a state tree object.

We can also write:

    computed: {
...mapState({
counter: (state) => state.counter
})
}

最新文章

  1. vue.js 的学习
  2. Java设计模式 - 适配器模式
  3. ELK笔记
  4. Sublime Text 3开启自动换行
  5. 地址标记,SpringMVC转发与调用相关知识存档
  6. php 7 windows redis 扩展
  7. 开发Android 范的错误
  8. Java中final变量的初始化方式
  9. django防止表单数据重复提交
  10. C++程序设计实践指导1.8求指定范围内的所有素数改写要求实现
  11. java 基于JDK中的源码总结下String二
  12. 【有意思的BUG】需要停止的进程
  13. HDU 2502 月之数(二进制,规律)
  14. Spring Cloud Consul使用——配置中心
  15. Ionic -- css
  16. Python操作MongoDB(PyMongo模块的使用)
  17. 检验二叉树序列化的合理性 Verify Preorder Serialization of a Binary Tree
  18. 在Azure DevOps Server (TFS) 中修改团队项目名称
  19. CSharp程序员学Android开发---2.个人总结的快捷键
  20. POJ 1252 Euro Efficiency(完全背包, 找零问题, 二次DP)

热门文章

  1. 小米开源文件管理器MiCodeFileExplorer-源码研究(6)-媒体文件MediaFile和文件类型MimeUtils
  2. 洛谷 P1400 塔
  3. Oracle Sqlplus中上下键出现^[[A乱码问题
  4. IIS下配置SilverLight
  5. HASH Partitioning--转载
  6. IIS进程回收 空闲时Net线程未运行
  7. python路径找类并获取静态字段
  8. 前端项目中常用es6知识总结 -- Promise逃脱回调地狱
  9. python处理文件
  10. Maven搭建hadoop环境报Missing artifact jdk.tools:jdk.tools:jar:1.7