19.uniapp组件通信 兄弟组件传值

一.首先有首页:index.vue

<template>
	<view class="content">
		<testA></testA>
		<testB></testB>
	</view>
</template>

<script>
	// ab组件
	import testA from '../../components/test/test-a.vue'
	import testB from '../../components/test/test-b.vue'
	
	export default {
		components:{
			testA,
			testB,
		},
</script>

<style>
</style>

二.test-a组件

<template>
	<view>
		<!-- 具体查看	框架页面页面通信 -->
		这是a组件 :<button @click="addNum">修改b组件的数据{
  {num}}</button>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				num:0,
			}
		},
		methods:{
			addNum(){
				uni.$emit('updateNum',10)
			}
		}
	}
</script>

<style>
</style>

三.test-b组件

<template>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值