当前位置:网站首页>兄弟组件进行传值(显示有先后顺序)
兄弟组件进行传值(显示有先后顺序)
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值喽
边栏推荐
- How awesome is the architecture of "12306"?
- 记一次使用Windbg分析内存“泄漏”的案例
- 2022新版PMP考试有哪些变化?
- 基于YOLOv3的口罩佩戴检测
- Crontab 日志:如何记录我的 Cron 脚本的输出
- Generate classes from XML schema
- 删除数组中的某几个元素
- "Xiaodeng in operation and maintenance" is a single sign on solution for cloud applications
- JVM third talk -- JVM performance tuning practice and high-frequency interview question record
- nano的CAN通信
猜你喜欢

About Estimation with Cross-Validation

Unicode processing in response of flash interface

mybash
![含重复元素取不重复子集[如何取子集?如何去重?]](/img/b2/d019c3f0b85a6c0d334a092fa6c23c.png)
含重复元素取不重复子集[如何取子集?如何去重?]

IDC report: Tencent cloud database ranks top 2 in the relational database market!

吳恩達團隊2022機器學習課程,來啦

职场进阶指南:大厂人必看书籍推荐

Record a case of using WinDbg to analyze memory "leakage"

Sophon CE社区版上线,免费Get轻量易用、高效智能的数据分析工具

How awesome is the architecture of "12306"?
随机推荐
LeetCode笔记:Weekly Contest 300
2022新版PMP考试有哪些变化?
Leetcode notes: Weekly contest 300
JVM third talk -- JVM performance tuning practice and high-frequency interview question record
破解湖+仓混合架构顽疾,星环科技推出自主可控云原生湖仓一体平台
Interpretation: how to deal with the current security problems faced by the Internet of things?
Tkinter window preload
Introduction to Resampling
Le cours d'apprentissage de la machine 2022 de l'équipe Wunda arrive.
[TestLink] testlink1.9.18 solutions to common problems
最大人工岛[如何让一个连通分量的所有节点都记录总节点数?+给连通分量编号]
Thesis reading_ Medical NLP model_ EMBERT
神经网络自我认知模型
寻找第k小元素 前k小元素 select_k
pytorch yolov5 训练自定义数据
Operation before or after Teamcenter message registration
Compared with the loss of Wenxin, the performance is improved a lot
Is it safe to open an account online? What is the general interest rate of securities financing?
小林coding的内存管理章节
图像分类,看我就够啦!