vue跨组件通信_跨打开的Vue标签的基于事件的通信

vue跨组件通信

提示事件 (vue-tabevents)

Easy communication between tabs for Vue 2.x.

Vue 2.x的选项卡之间易于通信。

vue-tabevents

入门 (Getting Started)

正在安装 (Installing)

Install with npm:

使用npm安装:

npm install --save vue-tabevents

import into project:

导入项目:

import Vue from 'vue';
import vueTabevents from 'vue-tabevents';

Vue.use(vueTabevents);

用法 (Usage)

To an emit event to other tabs

向其他选项卡发出事件

this.$tabEvent.emit('eventName');

const data = {
	name: 'Ali'
	phone: 123
}

this.$tabEvent.emit('eventName', data);

To listen for events emitted by other types

侦听其他类型发出的事件

this.$tabEvent.on('eventName', callback);

this.$tabEvent.on('eventName', (data) => console.log(data));

To stop listening to an event

停止收听事件

this.$tabEvent.off('eventName');

翻译自: https://vuejsexamples.com/event-based-communication-across-opened-tabs-for-vue/

vue跨组件通信

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值