简单的通信
来源:互联网 发布:淘宝闲鱼下载 编辑:程序博客网 时间:2024/06/02 02:07
1.父->子
父<template>
<div>
'我是父组件,我显示的内容是'{{mes}}
<Cc :from-p='mes'></Cc>
</div>
</template>
<script>
import Cc from './Cc.vue'
export default {
data(){
return {
mes:'我是父组件的内容'
}
},
components:{
Cc
}
}
</script>
子<template>
<div>
'我是子组件,我显示的内容是'{{mes}}
</div>
</template>
<script>
export default {
props:['fromP'],
data(){
return{
mes:this.fromP
}
}
}
</script>
2. 子->父
父<template>
<div>
'我是父组件,我显示的内容是'{{mes}}
<Cc @fromCc='chan'></Cc>
</div>
</template>
<script>
import Cc from './Cc.vue'
export default {
data() {
return {
mes: ''
}
},
methods: {
chan(da) {
this.mes = da;
}
},
components: {
Cc
}
}
</script>
子<template>
<div>
'我是子组件,我显示的内容是'{{mes}}
<button @click='toP'>虽然不允许,但是我想传给父组件</button>
</div>
</template>
<script>
export default {
data() {
return {
mes: '我是子组件的内容'
}
},
methods:{
toP(){
this.$emit('fromCc',this.mes)
}
}
}
</script>
3.平级传递vuex哈哈
- 简单的通信问题
- 简单的串口通信
- 简单的SOCKET通信
- 简单的操作通信
- 简单的Socket通信
- 简单的TCP通信
- 简单的UDP通信
- 简单的TCP通信
- 简单的AIDL通信
- 简单的UDP通信
- 蓝牙的简单通信
- 简单的TCP通信
- 简单的串口通信
- 简单的Socket通信
- 简单的Socket通信
- TCP简单的通信
- 简单的通信
- 简单的socket通信
- 【怎样写代码】偷窥高手 -- 反射技术(七):通过反射实例化对象
- Ubuntu小技巧积累
- list和数组相互转换
- HBase中涉及到的的一些设计理念
- Unity开发HTC vive(1)- 操作GUI、NGUI
- 简单的通信
- 批量梯度下降和随机梯度下降
- UnityShader入门精要学习笔记(十八):均值模糊与高斯模糊
- 判断SwipeRefreshLayout的childView是否到达顶部
- Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use. The
- context:conponent-scan和mvc:annotation-driven的作用?
- 设置端口映射或DMZ主机---将内网web服务器映射入公网
- Retrofit2封装之路(请求参数加密解密)(一)
- 数塔——DP算法