当前位置:网站首页>兄弟组件进行传值(显示有先后顺序)
兄弟组件进行传值(显示有先后顺序)
2022-07-05 17:56:00 【inticaler】
在开发中会遇到两个兄弟组件,哥哥执行完毕之后弟弟显示,哥哥隐藏,这种情况下我们就需要重新考虑执行先后顺序
比如
新建中间件,bus.js,让各个兄弟共用同一个传值事件机制。
import Vue from 'vue'
export default new Vue在child_1.vue(哥哥)组件中,绑定事件
import Bus from "@/utils/bus.js"
mounted() {
Bus.$on('getMergeId', this.getMergeId)
},
methods: {
getMergeId(callback) {
if (callback) callback(this.id);
},
}在child_2.vue(弟弟)组件中,触发事件获取值
import Bus from "@/utils/bus.js"
Bus.$emit("getMergeId", id => {
this.id = id
});然后就可以在弟弟组件中获取到哥哥组件的data值喽
边栏推荐
猜你喜欢

图像分类,看我就够啦!

Six bad safety habits in the development of enterprise digitalization, each of which is very dangerous!

Simulate the hundred prisoner problem

小林coding的内存管理章节

pytorch yolov5 训练自定义数据

Sophon autocv: help AI industrial production and realize visual intelligent perception

Redis基础

Anaconda中配置PyTorch环境——win10系统(小白包会)

「运维有小邓」用于云应用程序的单点登录解决方案

Elk log analysis system
随机推荐
What are the changes in the 2022 PMP Exam?
ISPRS2022/雲檢測:Cloud detection with boundary nets基於邊界網的雲檢測
隐私计算助力数据的安全流通与共享
Numerical calculation method chapter8 Numerical solutions of ordinary differential equations
基于YOLOv3的口罩佩戴检测
[TestLink] testlink1.9.18 solutions to common problems
Leetcode daily practice: rotating arrays
图片数据不够?我做了一个免费的图像增强软件
神经网络自我认知模型
Simulate the hundred prisoner problem
记一次使用Windbg分析内存“泄漏”的案例
[JMeter] advanced writing method of JMeter script: all variables, parameters (parameters can be configured by Jenkins), functions, etc. in the interface automation script realize the complete business
Cmake tutorial step5 (add system self-test)
Read libco save and restore the on-site assembly code
Wu Enda team 2022 machine learning course, coming
Isprs2022 / Cloud Detection: Cloud Detection with Boundary nets Boundary Networks Based Cloud Detection
Thesis reading_ Medical NLP model_ EMBERT
Anaconda中配置PyTorch环境——win10系统(小白包会)
Find the first k small element select_ k
开户复杂吗?网上开户安全么?