小编ran*_*ool的帖子

如何将空数组绑定到Vue.js3中的props?

<script lang="ts" setup>   
  interface Props {
    bigArray: string[];
  }
        
  ***const props = withDefaults(defineProps<Props>(), {
    bigArray:[],
  }*** <---- Here is the error, setting props
        
  const bigArray = ref(props.BigArray);
</script>
Run Code Online (Sandbox Code Playgroud)

ITsInterface.ts

BigArray?: string[] | null;
Run Code Online (Sandbox Code Playgroud)

在这种情况下寻找将空数组设置为 prop 的正确方法:

  • Vue.js3
  • 组合API
  • 打字稿
  • 在脚本标签中设置

arrays typescript vuejs3 vue-composition-api

2
推荐指数
1
解决办法
2128
查看次数

标签 统计

arrays ×1

typescript ×1

vue-composition-api ×1

vuejs3 ×1