Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.6k
-
我看文档上,vue需要通过observer包装组件,但是针对Vue3 的script setup,该怎么实现? script setup 组件样式: <template><div>{{ test }}</div></template><scriptsetup>consttest=1;</script> |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 6 replies
-
在当前组件内应该是无解的。不过可以试试另起一个文件导出 importComponentfrom'./component.vue'import{observer}from'@formily/reactive-vue'exportWrappedComponent=observer(Component) |
BetaWas this translation helpful?Give feedback.
All reactions
-
我看了看代码,好像可以用 useObserver 这个hooks?observer 其实也是在setup代码执行之前调用了useObserver。 |
BetaWas this translation helpful?Give feedback.
All reactions
-
噢对,可以,我给忘了😅 |
BetaWas this translation helpful?Give feedback.
All reactions
-
请问useObserver这个hooks是在哪个文档里的,找不到这个hooks。 |
BetaWas this translation helpful?Give feedback.
All reactions
-
@knight-peter 没有文档🤣,只有代码
|
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
还发现个更好点的办法,把 vue proxy之后的reactive再丢给 mobx,mobx makeProxy 之后再塞到 createForm({values: 这里}) constsource=ref({})// 再包一层 proxy,让 formily 往这里写就完事了。把 vue 的 ref 作为 formily 的数据源constval=observable(source.value);console.log(`isObservable`,isObservable(val));constform=createForm({values:val,}); |
BetaWas this translation helpful?Give feedback.