Skip to content

Commit c5fee4f

Browse files
committed
docs: additional expose limitations [tag patch] [skip ci]
1 parent a5348af commit c5fee4f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,26 @@ Unable to transform `TypeScript-only Features` of `defineEmits`, support only
191191
```ts
192192
const emit = defineEmits(['change', 'delete'])
193193
```
194+
195+
If `expose` is not specified, the reference may fail in the outer layer.
196+
197+
如果在 `script` 代码下子组件没有通过 `expose` 暴露内部状态,转换为 `setup` 代码后父组件将引用失败。
198+
199+
```ts
200+
// Child.vue
201+
export default {
202+
setup() {
203+
function foo() {}
204+
return { foo }
205+
}
206+
}
207+
208+
// Parent.vue
209+
export default {
210+
mounted() {
211+
// Child.vue is script code, it`s work
212+
// Child.vue is setup code, foo is undefined
213+
this.$refs.child.foo()
214+
}
215+
}
216+
```

0 commit comments

Comments
 (0)