Commit fa18f4df by chenwq1

fix(boutique): 修复组件实例调用方式

- 更新组件引用,添加 ComponentPublicInstance 类型
- 修改 callExposedMethod 函数,使用 $callMethod 确保稳定性
- 优化代码逻辑,增强类型安全性
1 parent b71ac8c1
......@@ -82,7 +82,7 @@
<script setup lang="uts">
import type { BoutiqueLogic } from "@/pages/boutique/useBoutiqueLogic.uts";
import { ref } from "vue";
import { ComponentPublicInstance, ref } from "vue";
import CenterPopup from "@/components/CenterPopup.uvue";
import HomeFrame from "@/components/HomeFrame/index.uvue";
......@@ -99,11 +99,8 @@ const packageRef = ref(null);
function callExposedMethod(comp: any, methodName: string): void {
if (comp == null) return;
const obj = comp as UTSJSONObject;
const fn = obj[methodName];
if (fn != null && typeof fn === "function") {
(fn as () => void)();
}
// uni-app x 组件实例在运行时不一定能 cast 成 UTSJSONObject;用 $callMethod 最稳
(comp as ComponentPublicInstance).$callMethod(methodName);
}
function handleStart(): void {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!