1.Vue 组件间通信有哪几种方式?
https://juejin.im/post/5cde0b43f265da03867e78d3
(1)props / $emit 适用 父子组件通信
(2)ref 与 $parent /
emit /
attrs/$listeners 适用于 隔代组件通信
(5)provide / inject 适用于 隔代组件通信
(6)Vuex 适用于 父子、隔代、兄弟组件通信,
https://blog.csdn.net/wh710107079/article/details/88181015
2. js存储方式cookie/sessionStorage/localStorage/indexedDB区别用法
https://blog.csdn.net/qq_29132907/article/details/80389398
3.VUEX的用法
module.exports = {
usecard: '',
givescorememberName: '',
};
mutation.js更改数据
module.exports = {
GIVESCOREMEMBERNAME:(state,payload)=>{
state.givescorememberName=payload;
},
};
存储数据原生用法
this.$store.commit('GIVESCOREMEMBERNAME',aaa);
更改数据原生用法
this.givescorememberName=this.$store.state.givescorememberName;
存储数据解构用法
import {mapMutations} from 'vuex';
methods:{
...mapMutations(["GIVESCOREMEMBERNAME"]),
this.GIVESCOREMEMBERNAME(aaa);
},
更改数据解构用法
import {mapState} from 'vuex';
computed:{
...mapState(['givescorememberName']),
},