VUE组件间通信/参数传递

1.Vue 组件间通信有哪几种方式?

https://juejin.im/post/5cde0b43f265da03867e78d3
(1)props / $emit 适用 父子组件通信
(2)ref 与 $parent / c h i l d r e n 3 E v e n t B u s children 适用 父子组件通信 (3)EventBus ( emit / o n 4 on) 适用于 父子、隔代、兄弟组件通信 (4) 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的用法

https://blog.csdn.net/weixin_35955795/article/details/57412181?ops_request_misc=&request_id=&biz_id=102&utm_source=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-0
state.js存储数据

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']),
    },

4.query和params的区别

https://blog.csdn.net/mf_717714/article/details/81945218

发布了25 篇原创文章 · 获赞 0 · 访问量 1413

猜你喜欢

转载自blog.csdn.net/SuperxApple/article/details/103513144
今日推荐