ionic 4-添加插件时出现Uncaught TypeError [英] ionic 4 - Uncaught TypeError when add plugin

查看:67
本文介绍了ionic 4-添加插件时出现Uncaught TypeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个离子项目(版本:4.0.6).从 https://添加插件cordova-plugin-x-socialsharing后,我遇到以下错误beta.ionicframework.com/docs/native/social-sharing . 我被困在这里.有人可以帮我吗.

I have created an ionic project(version: 4.0.6). I am getting below error after adding the plugin cordova-plugin-x-socialsharing from https://beta.ionicframework.com/docs/native/social-sharing. I am stuck here. Could anybody help me on this please.

index.js:413 Uncaught TypeError: Object(...) is not a function
    at index.js:413
    at Object../node_modules/@ionic-native/social-sharing/index.js (index.js:590)
    at __webpack_require__ (bootstrap:81)
    at Object../src/app/app.module.ts (app.global.ts:10)
    at __webpack_require__ (bootstrap:81)
    at Object../src/main.ts (environment.ts:15)
    at __webpack_require__ (bootstrap:81)
    at Object.0 (main.ts:12)
    at __webpack_require__ (bootstrap:81)
    at checkDeferredModules (bootstrap:43)

更新:我今天找到了一个解决方案! 步骤1:将package.json中的插件版本更改为package.json中显示的@ ionic-native/core相同版本. 步骤2:删除node_module并运行npm install. 第三步:在导入时,在末尾添加"/ngx",如下所示; 从'@ ionic-native/social-sharing/ngx'导入{SocialSharing}; 步骤4:与离子2或离子3一样休息

Update: I found one solution today! step1: change version of plugin in package.json to the same version of @ionic-native/core that shown in the package.json. Step 2: remove node_module and run npm install. Step 3: add '/ngx' at the end when import it like below; import { SocialSharing } from '@ionic-native/social-sharing/ngx'; step 4: do rest same as ionic 2 or 3

推荐答案

现在已从@ionic-native/plugin-xxx/ngx导入Angular版本.

The Angular versions are now imported from @ionic-native/plugin-xxx/ngx.

这篇关于ionic 4-添加插件时出现Uncaught TypeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆