Vue
来源:互联网 发布:字母大小写转换c语言 编辑:程序博客网 时间:2024/06/05 16:05
组件
1、定义组件
2、注册组件
<script type="text/x-template" id="child-tpl"> <input v-model="msg"/> <button v-on:click="notify">触发</button> </script> <!--start <template id="child-tpl"> <input v-model="msg"/> <button v-on:click="notify">触发</button> </template> 子组件 -->
// 第一种 通用组件定义var Child = Vue.extend({ template:'#child-tpl', data:function(){ return { msg:'good ' }; }, methods:{ notify:function(){ if(this.msg.trim()){ this.$dispatch('child-msg',this.msg); this.msg = ''; } } }});Vue.compoent('child',Child);// 第二种 语法糖形式Vue.component('child',{ template:'#child-tpl', data:function(){ return { msg:'good ' }; }, methods:{ notify:function(){ if(this.msg.trim()){ this.$dispatch('child-msg',this.msg); this.msg = ''; } } }}); var App = new Vue({ el:'#demo', data:{ messges:[] }, methods:{ 'handleChild':function(mes){ this.messges.push(mes); } } });
0 0
- Vue
- vue
- vue
- Vue
- Vue
- vue
- vue
- vue
- vue
- vue
- vue
- vue
- vue
- VUE
- vue
- vue
- Vue
- Vue
- mac10.11使用中遇到的那些问题及解决办法
- C++ Scope Exit
- button跟submit的区别及使用js实现页面跳转的方式
- vim编辑器的使用
- Emacs 使用
- Vue
- Android开发--基础联网框架Xutils3
- 汇编语言 指令 机器码三者的关系
- Qt遇到链接问题
- HDFS 原理、架构与特性介绍
- TableViewCell的另一种3D效果
- 实现按指定字母序进行排序
- bitnami redmine 插件的安装
- is not allowed to connect to this MySql server