1***@qq.com
1***@qq.com
  • 发布:2025-09-03 15:16
  • 更新:2025-09-03 15:16
  • 阅读:22

uniapp 是否可以使用微信小程序原生插件,例如小说阅读器插件

分类:uni-app

小说阅读器插件链接:插件介绍文档

该如何使用呢?在 menifest.json 中配置了:

    /* 小程序特有相关 */  
    "mp-weixin": {  
        "appid": "xxxxxxxxxxxxxxxxxxxxxx",  
        "setting": {  
            "urlCheck": false,  
            "minified": true  
        },  
        "usingComponents": true,  
        "plugins": {  
            "novel-plugin": {  
                "version": "latest",  
                "provider": "wx293c4b6097a8a4d0"  
            }  
        }  
    },

在页面 vue 代码中配置:

    onLoad() {  
        const novelPlugin = uni.requireNativePlugin('novel-plugin')  
        console.log(111, novelPlugin)  
        if (novelPlugin) {  
            novelPlugin.onPageLoad(this.onNovelPluginLoad)  
        }  
    },

发现会报错

TypeError: common_vendor.index.requireNativePlugin is not a function  
    at Proxy.onLoad (bookIntro.vue:123)  
    at callWithErrorHandling (vue.runtime.esm.js:1356)  
    at callWithAsyncErrorHandling (vue.runtime.esm.js:1363)  
    at Array.hook.__weh.hook.__weh (vue.runtime.esm.js:2461)  
    at invokeArrayFns (uni-shared.es.js:441)  
    at Proxy.callHook (uni.mp.esm.js:206)  
    at li.methods.onLoad (uni.mp.esm.js:792)  
    at li.<anonymous> (VM2937 WASubContext.js:1)  
    at li.c.__callPageLifeTime__ (VM2937 WASubContext.js:1)  
    at VM2937 WASubContext.js:1(env: Windows,mp,1.06.2504030; lib: 3.9.2)
2025-09-03 15:16 负责人:无 分享
已邀请:

要回复问题请先登录注册