您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页Vue - 嵌套组件(Nested Component)

Vue - 嵌套组件(Nested Component)

来源:二三娱乐
图片.png

eg:
item.vue

<template>
  <div :class="['todo-item',  ? 'complated' : '']">
    <input
      type="checkbox"
      class="toggle"
      
    >
    <label>{{ todo.content }}</label>
    <button class="destory" @click="deleteTodo"></button>
  </div>
</template>


<script>

  export default{
    props: {
      todo: {
        type: Object,
        required: true,
      }
    },
    methods: {
      deleteTodo: function () {
        
      }
    }
  }
</script>

<style scoped>
</style>

todo.vue

<script>

  import Item from './item.vue'

  export default{
    data(){
      return {msg: 'hello vue'}
    },
    components: {   // 注册Item组件为自己的组件
      Item,
    },
    methods: {
      addTodo() {

      }
    }
  }
</script>

todo.vue包含item组件为嵌套组件。

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务