Vue 组件引入子组件v-for

  当父组件引入子组件时,v-for 遍历对象,会显示对象有多少个属性和方法,为遍历出显示次数。

      而v-for 遍历数组,则遍历显示一次。

父组件

   <!--引入子组件  子组件,在子组件 v-for 指令遍历对象,会循环显示次数为对象有多少属性和方法-->
    <compontentA v-for="(value, key) in ObjList"
         :key="key"
         :class="{odd: key % 2}">
      {{ value}} -- {{ key }}
    </compontentA>

子组件

<template>
  <h1 >{{ NewDate}}</h1>
</template>
<script>
  export default {
      data(){
          return {
              NewDate:'组件内联--列表项'
          }
      }
  }
</script>
<style scoped>

</style>

猜你喜欢

转载自www.cnblogs.com/branchTree/p/9693593.html