zoukankan      html  css  js  c++  java
  • vue语法01

    <div id="app">
        <todo>
            <todo-title slot="todo-title" :title="title"></todo-title>
            <todo-item slot="todo-item" v-for="(item,index) in items" :item="item" :index="index" v-on:remove="removeItems"></todo-item>
        </todo>
    </div>
    
    
    
    
     //todo组件
        Vue.component('todo',{
            template: '<div>'+
    				'<slot name="todo-title"></slot>'+
    				'<slot name="todo-item"></slot>'+
    				'</div>'
        })
        //标题组件
        Vue.component('todo-title',{
            props:['title'],
            template: '<div>{{title}}</div>'
        })
        //内容组件
        Vue.component('todo-item',{
            props:['item','index'],
            template:'<li>{{index}}--->{{item}} <button @click="remove">删除</button></li>',
            methods:{
                remove:function () {
                    this.$emit('remove');
                }
            }
        })
        var app = new Vue({
            <!-- el,element缩写,挂载元素 -->
            el: '#app',
            data:{
                title:'待办事项',
                items:['迪丽热巴','古力娜扎','玛尔扎哈']
            },
            methods:{
                removeItems:function (index) {
                    this.items.splice(index,1);
                }
            }
        })
    

      

    this.$emit("remove") 绑定自定义事件 v-on:remove="removeTime" 然后绑定父类的方法removeTime

      

  • 相关阅读:
    11.变分推断
    10.高斯混合模型GMM
    9.EM 算法
    8.指数族分布
    7.概率图模型(表示/推断/学习)
    6.核方法
    二分查找
    2.3 数据结构---数组(连续)
    C#开发Windows服务的基础代码
    C#与C++之间类型的对应{转}
  • 原文地址:https://www.cnblogs.com/LWMLWM/p/14329375.html
Copyright © 2011-2022 走看看