vue组件 子组件没有事件怎么 向父组件传递数据
2024-10-22 04:58:26
通过ref去接收值!!!
需求图片
代码实现
//----------父组件
<div class="fingerprint-bottom">
<el-tabs v-model="activeName">
<el-tab-pane v-for="(item,index) in optionS" :key="index" :label="item.label" :name="item.name">
<EditAssetTab :ref="item.type" type="item.type" :edit-asset-data="editAssetData" :active-name="item.name" />
</el-tab-pane>
</el-tabs>
</div>
// 提交按钮
submitAsset() {
// 调用子组件的获取数据方法
const refsMap = ['a', 'b', 'c', 'd', 'e', 'f'];
refsMap.map(item => {
this.originData = { ...this.originData, ...this.$refs[item].getAllQuery() };
});
}
// ------子组件 //获取组件所有参数
getAllQuery() {
if (this.type === 'a') { // a->为父组件的ref的值
return {
ip_type: this.ip_type, // IP类型
ip_nat: this.ip_nat, // 映射IP
};
............
}
最新文章
- scala 宏
- 矢量化的HTML5拓扑图形组件设计
- 我开发 wangEditor-mobile 的故事
- NetCFSvcUtil.exe and Windows 7
- iOS开发之网络编程--中文转码
- layoutSubviews 浅尝
- Nginx,LVS,HAProxy,负载均衡之选择
- php 的一个pg_fetch_assoc的怪问题
- 关于ubuntu16.04给firefox安装flash的补充
- android之IntentFilter的用法_Intent.ACTION_TIME_TICK在manifest.xml不起作用
- windows(win10)下的mysql解压版安装
- nuget服务器搭建,以及如何发布一个Nuget包
- 帮Python找“对象”
- 【SAP HANA】SAP HANA开篇(1)
- js之省市区(县)三级联动效果
- 实现div里的img图片水平垂直居中
- 颜色 color
- AppStore企业账号打包发布APP流程详解
- PS合成的5个要点:场景、对比、氛围、模糊、纹理
- Python进阶-字符串格式化