最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vue.js - Passing ref to child component without unwrapping - Stack Overflow

programmeradmin3浏览0评论

How do we pass a ref to a child prop without getting it unwrapped by Vue? I have tried several things including toRef, reactive, shallowRef among others, but it keeps complaining about the type of this prop not matching the passed value. I'm using latest Vue with Typescript and script setup.

Child component

Defines a prop of type Ref<Canvas> (Canvas is from fabric.js):

const props = defineProps<{
  canvas: Ref<Canvas>
}>()

Parent component

<ChildComponent :canvas="c" />
...
const c = ref<Canvas>(theCanvasObject)
...
发布评论

评论列表(0)

  1. 暂无评论