当前位置:网站首页>兄弟组件进行传值(显示有先后顺序)
兄弟组件进行传值(显示有先后顺序)
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值喽
边栏推荐
猜你喜欢

Nanjing University: Discussion on the training program of digital talents in the new era

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

How awesome is the architecture of "12306"?

模拟百囚徒问题

图扑软件数字孪生 | 基于 BIM 技术的可视化管理系统

Privacy computing helps secure data circulation and sharing

About Estimation with Cross-Validation

JVM第三话 -- JVM性能调优实战和高频面试题记录

Sophon base 3.1 launched mlops function to provide wings for the operation of enterprise AI capabilities

职场进阶指南:大厂人必看书籍推荐
随机推荐
Cmake tutorial step5 (add system self-test)
Image classification, just look at me!
Binder开辟线程数过多导致主线程ANR异常
Sophon Base 3.1 推出MLOps功能,为企业AI能力运营插上翅膀
mybash
What are the changes in the 2022 PMP Exam?
南京大学:新时代数字化人才培养方案探讨
Cmake tutorial Step4 (installation and testing)
数值计算方法 Chapter8. 常微分方程的数值解
Interpretation: how to deal with the current security problems faced by the Internet of things?
隐私计算助力数据的安全流通与共享
从XML架构生成类
Thesis reading_ Chinese NLP_ LTP
Star ring technology data security management platform defender heavy release
「运维有小邓」用于云应用程序的单点登录解决方案
吳恩達團隊2022機器學習課程,來啦
Introduction to Resampling
Is it safe to open an account online? What is the general interest rate of securities financing?
Leetcode notes: Weekly contest 300
Memory management chapter of Kobayashi coding