vue实现父子双向通信
来源:互联网 发布:峡山网店美工培训 编辑:程序博客网 时间:2024/06/14 09:03
- 父组件通过props向子组件传递数据
- 子组件用emit向父组件传递数据
父子组件同时操作同一个数,进行加运算与减运算
- 子组件 counter.vue
<template> <div> <button v-on:click=increament>+</button> <button @click=decreament>-</button> <p>{{num}}</p> </div></template><script> export default { props: ["num"], methods: { increament: function() { this.$emit("incre"); }, decreament: function() { this.$emit("decre"); } } }</script>
- 父组件
<template> <div class="hello"> <counter v-bind:num ="num" v-on:incre="increment" v-on:decre = "decrement"></counter> <p>parent:{{num}}</p> </div></template><script> import counter from "./counter"export default { name: 'hello', data () { return { num:10 } }, components:{ counter }, methods:{ increment:function(){ this.num ++; }, decrement:function(){ this.num --; } }}</script>
阅读全文
0 0
- vue实现父子双向通信
- vue.js学习笔记(六)--利用v-model实现父子组件间的双向通信
- 利用v-model实现父子组件间的双向通信
- vue如何实现父子组件通信,以及非父子组件通信(待看)
- 客户端服务器端实现双向通信
- vue 父子组件通信
- vue非父子通信
- vue父子组件通信
- Vue父子组件通信
- Vue父子组件通信
- Vue父子组件创建
- vue父子传值
- Vue父子通信 props
- vue父子组件中传值
- vue父子组件通信
- 微信小程序框架wepy.js父子组件双向通信
- 如何通过Remoting实现双向通信
- 如何通过Remoting实现双向通信
- Asp.Net Core MVC设计模式
- Java学习过程中出现的异常问题与处理(最近更新20170915)
- request:fail ssl hand shake error 微信小程序Android真机调试问题
- 【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二进制和源码安装
- Object Recognition 对象识别
- vue实现父子双向通信
- Redhat6.5-Python2.7及插件安装 # 1.修改环境变量 #echo '****** 1.修改PATH环境变量增加jdk1.7.0_65路径 *******' #echo ' # #
- javascript数据类型
- web前端素材整理汇总
- 【5-1】使用命令
- Eclipse之Hibernate插件
- opengl与多媒体是怎么窜起来的?
- git 的一个报错
- Educational Codeforces Round 27-搜索&技巧&异或-G. Shortest Path Problem?