vuejs 子组件传递父组件的第一种方式
2017-01-15 20:06
253 查看
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>vue-dmeo</title> <script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> </head> <body> <div id="page"> <hellow v-on:child-msg="handleIt"></hellow> {{arr|json}} </div> <script type="text/javascript" src="//cdn.bootcss.com/vue/1.0.26/vue.js"></script> <script> var handle= function(){ var hellow = { template:"<div style='color:#f00;text-align:center;'><input type='text' v-model='mess' /><button @click='csend()'>点击</button>{{mess}}</div>", methods:{ csend:function(){ if(this.mess.trim()){ this.$emit('child-msg',this.mess); this.mess=''; } } } } return new Vue({ el:"#page", data:{ arr:[], }, methods:{ handleIt:function(msg){ this.arr.push(msg); } }, components:{ hellow:hellow, } }) }() </script> </body> </html>
相关文章推荐
- vuejs 子组件传递父组件的第二种方式
- Vuejs第九篇之组件作用域及props数据传递实例详解
- Vue 父子组件数据传递的四种方式( inheritAttrs + $attrs + $listeners)
- Android组件间通信机解耦——Android EventBus和Otto框架一、前言 传统的事件传递方式包括:Handler、BroadCastReceiver、Interface 回调,相比之
- Vue 父子组件传递方式
- Vue 父子组件传递方式
- vuejs 父组件向子组件传递($broadcast()的用法)
- Angular2-组件间数据传递的两种方式
- 详解vuejs几种不同组件(页面)间传值的方式
- vue父子组件数据传递方式
- 开始使用 Vuejs 2.0 --- 组件间数据传递
- vuejs动态组件给子组件传递数据的方法详解
- React组件间信息传递方式
- vuejs几种不同组件(页面)间传值的方式
- vue两个组件间值的传递或修改方式
- 以SceneProxy的方式由逻辑线程向渲染线程传递数据来自定义渲染组件
- React组件间信息传递方式
- vuejs几种不同组件(页面)间传值的方式
- vuejs几种不同组件(页面)间传值的方式
- vuejs动态组件给子组件传递数据