提交 7d7b1eb9 编写于 作者: F fxy060608

refactor: 调整 customRef 参数返回值类型

上级 4b21f575
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<script setup lang="uts"> <script setup lang="uts">
const useCustomRef = (value : UTSJSONObject) : Ref<UTSJSONObject> => { const useCustomRef = (value : UTSJSONObject) : Ref<UTSJSONObject> => {
// @ts-ignore // @ts-ignore
return customRef<UTSJSONObject>((track, trigger) : UTSJSONObject => { return customRef<UTSJSONObject>((track, trigger) => {
return { return {
get() : UTSJSONObject { get() : UTSJSONObject {
track() track()
...@@ -26,14 +26,15 @@ const useCustomRef = (value : UTSJSONObject) : Ref<UTSJSONObject> => { ...@@ -26,14 +26,15 @@ const useCustomRef = (value : UTSJSONObject) : Ref<UTSJSONObject> => {
value = newValue value = newValue
trigger() trigger()
} }
} as UTSJSONObject }
}) })
} }
const state = useCustomRef({ count: 0 } as UTSJSONObject) const state = useCustomRef({ count: 0 })
const increment = () => { const increment = () => {
(state.value as UTSJSONObject)['count'] = ((state.value as UTSJSONObject)['count'] as number) + 1 state.value['count'] = (state.value['count'] as number) + 1
} }
const triggerRefState = () => { const triggerRefState = () => {
triggerRef(state) triggerRef(state)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册