有问
有问
  • 发布:2025-08-17 21:20
  • 更新:2025-08-18 11:50
  • 阅读:75

请教一下公共方法函数如何推导?

分类:uni-app x

X中只能单独推导了

2025-08-17 21:20 负责人:无 分享
已邀请:
DCloud_UNI_JBB

DCloud_UNI_JBB

你的完整的代码怎么写的

  • 有问 (作者)

    mixin.ts


    export const mixin= {


    domain:"test",


    getCurrDatetime:((full:Boolean){


    return "ssss"


    })


    }


    然后在man.uts中


    import {mixin} from ....


    app.config.globalProperties.$mixin=mixin as UTSJSONObject;//混入


    index.uvue


    使用setup


    proxy=getCurrentInstance()?.proxy;

    const mixin=ref<UTSJSONObject>(proxy?.$mixin as UTSJSONObject)

    在onShow中,测试延迟输出


    console.log(mixin.value?.domain) //这个输出成功为test


    但mixin.value?.getCurrDatetime(false) 这个方法就一直提示:‌⁠error: Unresolved reference: getCurrDatetime‌

    2025-08-18 12:27

要回复问题请先登录注册