当前位置:网站首页>兄弟组件进行传值(显示有先后顺序)
兄弟组件进行传值(显示有先后顺序)
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值喽
边栏推荐
- 访问数据库使用redis作为mysql的缓存(redis和mysql结合)
- Sophon autocv: help AI industrial production and realize visual intelligent perception
- tkinter窗口预加载
- 图片数据不够?我做了一个免费的图像增强软件
- Sophon CE Community Edition is online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool
- 小白入门NAS—快速搭建私有云教程系列(一)[通俗易懂]
- Action avant ou après l'enregistrement du message teamcenter
- 从XML架构生成类
- VC编程入门浅谈「建议收藏」
- Eliminate the writing of 'if () else{}'
猜你喜欢
Sophon Base 3.1 推出MLOps功能,为企业AI能力运营插上翅膀
Memory management chapter of Kobayashi coding
Daily exercise: a series of dates
Nanjing University: Discussion on the training program of digital talents in the new era
寻找第k小元素 前k小元素 select_k
IDC report: Tencent cloud database ranks top 2 in the relational database market!
第十一届中国云计算标准和应用大会 | 华云数据成为全国信标委云计算标准工作组云迁移专题组副组长单位副组长单位
Anaconda中配置PyTorch环境——win10系统(小白包会)
Sophon CE Community Edition is online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool
EPM相关
随机推荐
第十一届中国云计算标准和应用大会 | 华云数据成为全国信标委云计算标准工作组云迁移专题组副组长单位副组长单位
How to modify MySQL fields as self growing fields
FCN: Fully Convolutional Networks for Semantic Segmentation
“12306” 的架构到底有多牛逼?
What are the changes in the 2022 PMP Exam?
Matlab reference
小林coding的内存管理章节
Matlab built-in function how different colors, matlab subsection function different colors drawing
Leetcode notes: Weekly contest 300
Isprs2022 / Cloud Detection: Cloud Detection with Boundary nets Boundary Networks Based Cloud Detection
Size_ T is unsigned
ISPRS2022/雲檢測:Cloud detection with boundary nets基於邊界網的雲檢測
吴恩达团队2022机器学习课程,来啦
删除数组中的某几个元素
Delete some elements in the array
多线程(一) 进程与线程
rsync
Easynmon Usage Summary
Eliminate the writing of 'if () else{}'
怎么选择外盘期货平台最正规安全?