小编lea*_*ode的帖子

如何在vue3组合API中获取道具

我尝试编写一个容器组件“A”来布局第三方组件“Tree”,为了使用A,我使用“inheritAttrs”来获取“Tree”的所有道具和事件:

<template>
    <Tree v-bind="$attrs" />
</template>
<script lang="ts">
  export default {
    inheritAttrs: true,
  };
</script>
<script lang="ts" setup>
  import { Tree } from 'ant-design-vue';
  import { onMounted, PropType, toRef, unref, ref, toRefs } from 'vue';
  function A() {
      // this is not working
      console.log(props);
   }

</script>
Run Code Online (Sandbox Code Playgroud)

如何在函数 A 中获得从“Tree”继承的一些 props 属性?

vuejs3

26
推荐指数
2
解决办法
5万
查看次数

标签 统计

vuejs3 ×1