vuex & redux

https://vuex.vuejs.org/

https://github.com/xgqfrms/VAIO/

https://scrimba.com/playlist/pnyzgAP

vuex

https://vuex.vuejs.org/zh/

data flow


Structure and manage Vuex store with Modules

https://scrimba.com/p/pnyzgAP/cqKK4psq

https://markus.oberlehner.net/blog/how-to-structure-a-complex-vuex-store/

https://vuex.vuejs.org/guide/structure.html

https://vuex.vuejs.org/guide/modules.html

action & mapActions

https://vuex.vuejs.org/zh/guide/actions.html

alias name bug

  1. this.increment() 映射为 this.$store.dispatch('increment')

  2. this.add() 映射为 this.$store.dispatch('increment')


import { mapActions } from 'vuex' export default {
// ...
methods: {
...mapActions([
'increment', // 将 `this.increment()` 映射为 `this.$store.dispatch('increment')` // `mapActions` 也支持载荷:
'incrementBy' // 将 `this.incrementBy(amount)` 映射为 `this.$store.dispatch('incrementBy', amount)`
]),
...mapActions({
add: 'increment' // 将 `this.add()` 映射为 `this.$store.dispatch('increment')`
})
}
}

namespace & path


import Vue from 'vue';
import Vuex from 'vuex'; Vue.use(Vuex); const moduleA = {
namespaced: true,
state: {
count: 3
},
mutations: {
increment (state) {
state.count++
}
},
getters: {
doubleCount (state) {
return state.count * 2
}
},
actions: {
incrementIfOdd({state, commit}) {
if (state.count % 2 === 1) {
commit('increment');
}
}
}
} const moduleB = {
state: {
count: 8
},
mutations: { },
getters: { },
actions: { }
} const store = new Vuex.Store({
modules: {
a: moduleA,
b: moduleB
},
state: {
count: 2
},
mutations: { },
getters: { },
actions: { }
}) new Vue({
el: '#app',
store,
data: {
},
computed: {
}
}); console.log(store.state.a.count);
// console.log(store.state.b.count);
store.commit('a/increment');
console.log(store.state.a.count);

bugs & warns

https://vuejs.org/v2/guide/deployment.html

index.pack.js:736 [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.


redux

https://redux.js.org/basics/data-flow

data flow

https://github.com/reduxjs/redux/issues/653

https://redux.js.org/basics/usage-with-react

https://redux.js.org/advanced/usage-with-react-router

https://redux.js.org/basics/basic-tutorial

https://redux.js.org/advanced/advanced-tutorial




SSR

服务端渲染

https://cn.vuejs.org/v2/guide/ssr.html

https://ssr.vuejs.org/zh/


vuex & redux的更多相关文章

  1. react的Redux基础

    redux的中文文档:http://www.redux.org.cn/ redux的英文官网:https://redux.js.org/ redux相当于vuex Redux 是 JavaScript ...

  2. Vue开源项目库汇总

    最近做了一个Vue开源项目库汇总,里面集合了OpenDigg 上的优质的Vue开源项目库,方便移动开发人员便捷的找到自己需要的项目工具等,感兴趣的可以到GitHub上给个star. UI组件 elem ...

  3. Vue常用经典开源项目汇总参考-海量

    Vue常用经典开源项目汇总参考-海量 Vue是什么? Vue.js(读音 /vjuː/, 类似于 view) 是一套构建用户界面的 渐进式框架.与其他重量级框架不同的是,Vue 采用自底向上增量开发的 ...

  4. Vue常用开源项目汇总

    前言:Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架.与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用.Vue 的核心库只关注视图层,不仅易于上手,还 ...

  5. Vue应用框架整合与实战--Vue技术生态圈篇

    实用框架以及工具 UI组件 开发框架 实用库 服务端 辅助工具 应用实例 Demo示例 UI组件 Element-UI ★13489 - 饿了么出品的Vue2的web UI工具套件 Vux ★8133 ...

  6. vue各种插件汇总

    https://blog.csdn.net/wh8_2011/article/details/80497620(copy) Vue是什么? Vue.js(读音 /vjuː/, 类似于 view) 是一 ...

  7. VUE插件大总结

    UI组件 element - 饿了么出品的Vue2的web UI工具套件 Vux - 基于Vue和WeUI的组件库 mint-ui - Vue 2的移动UI元素 iview - 基于 Vuejs 的开 ...

  8. Vue相关开源项目库汇总

    https://github.com/opendigg/awesome-github-vue http://www.opendigg.com/tags/front-vue README.md 内容 U ...

  9. vue插件大全汇总

    Vue是一个构建数据驱动的 web 界面的渐进式框架.Vue.js 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件特别整理了常用的vue插件,来了个大汇总,方便查找使用,便于工作 ...

随机推荐

  1. Hash Array Mapped Trie

    Hash Array Mapped Trie   Python\hamt.c

  2. Python学习【第9篇】:python中的局部变量与全局变量

    1.全局变量 全局变量定义后可被下面所有函数进行调用 例子: name = "xiao"def chang_name(): print("chang_name" ...

  3. bzoj2654(loj20069)

    2654: tree Time Limit: 30 Sec  Memory Limit: 512 MB Description 给你一个无向带权连通图,每条边是黑色或白色.让你求一棵最小权的恰好有ne ...

  4. cogs 2566 字符串最大值

    2566. [51nod 1129] 字符串最大值 ★★   输入文件:string_maxval.in   输出文件:string_maxval.out   简单对比时间限制:1 s   内存限制: ...

  5. python学习:随机数的产生,随机数拼接字在脚本中的应用

    学习random的时候,看到一份表格觉得不错,转载记录到自己的笔记中: random以及它们在numpy.random中对应的函数应该会很有帮助: 注意:NumPy专门用于构建和操作大型多维数组.如果 ...

  6. HTTPS是怎么保证数据安全传输的?

    前言 关于HTTPS的连接过程,也是老生常谈的话题了. 其中涉及到的数字证书.电子签名.SSL/TLS.对称加密.非对称加密的问题总是让人摸不清头脑,不知道怎么回答. 今天就和大家再熟悉熟悉这其中千丝 ...

  7. Kafka踩坑填坑记录

    Kafka踩坑填坑记录 一.kafka通过Java客户端,消费者无法接收消息,生产者发送失败消息 二. 一.kafka通过Java客户端,消费者无法接收消息,生产者发送失败消息 在虚拟机上,搭建了3台 ...

  8. Linux环境mysql快速备份及迁移

    在项目实施的过程中,经常会面临数据库迁移,导出和导出数据,如果用普通的mysql客户端备份,时间较长且容易出错.那么mysql快速备份及迁移,就成为数据库迁移的重中之重. 下面介绍我在项目实现过程中用 ...

  9. java 读取text内容

    public static String readToString(String fileName) { String encoding = "UTF-8"; File file ...

  10. MyEclipse配置maven以及项目jar包更改

    将压缩包解压,路径中不要包含中文,我解压的路径是D:\JAVA\apache-maven-3.0.5 新建环境变量M2_HOME 指向D:\JAVA\apache-maven-3.0.5 在path中 ...