vue父组件给子组件传值

本文探讨了在Vue中如何从父组件向子组件传递值,包括在父组件引用子组件的事件触发及子组件使用$refs接收和响应数据的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

vue父组件给子组件传值

父组件拉起的弹窗如何把值传过去

1、在 父页面应用子页面的地方添加@refreshDataList="getDataList

<template>
	<div>
		// <!-- 通过点击事件拉起弹框显示内容 -->
		 <el-button @click="detailHandle(scope.row.id)" type="text" size="small">查看详情</el-button>
		//  <!-- 弹框模块 父页面应用子页面的地方添加-->
		 <detail ref="detail" @refreshDataList="getDataList" :pwidth="dWidth"></detail>
	 </div>
 </template>

<script>
 import detail from '../financingApply/financingApply-detail';  //弹窗内容部分
  export default {
  	name: "***",
  	 data() {
  		 return {}
  	 }
    components: {
            detail
    },
	methods: {
		//点击事件
 		detailHandle(id){
                this.$nextTick(() => {
              		//父页面传给子页面
                    this.$refs.detail.init(id);
                });
            },
       getDataList() {
        //getDataList方法里可以些业务逻辑
           this.dataListLoading = true
       }
	}
  }

</script>

在子页面中调用

//在子页面中调用
detailHandle: () => {
              this.$emit("refreshDataList")
            }

this.$refs:父组件向子组件通信,可以调用子组件里的属性和方法

this.$emit:子组件向父组件通信

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值