Vue的v-bind="$attrs"如何使用

/这是是爷爷组件

<template>
  /传两个prop,parent和child
  <parent parent='40' child="18"/>
</template>
<script>
export default{
  name:"grandpa"
}
</script>


//这是是爸爸组件
<template>
  <child v-bind = '$attrs'/>
  <span>{{parent}}</span>//40
</template>
<script>
  export default {
    name:"parent",
    props:['parent']
  }
</script>

//这是儿子组件
<template>
  <span>{{child}}</span>//18
</template>
<script>
  export default {
    name:"child",
    props:['child']
  }
</script>

 

posted on 2022-06-15 14:36  久居我梦  阅读(261)  评论(0编辑  收藏  举报

导航