简体   繁体   中英

How to import modules in js files as you do in typescript?

So basically the problem is this. I need to use some FCM cordova plugins in my ionic v3 project, this project as been modify so it is based in javascript.

I need to be able to import modules as I usually do in typescript files, I mean do something like this:

import { FCM } from '@ionic-native/fcm';

But in js, so I can use methods and functions of these plugins and components in js

Currently, I'm trying by using require.js since guys bellow gave me the idea:

var FCM = '@ionic-native/fcm';
require([FCM], function(fcmodule){
    // use module
})

but it is not working so far, I'm getting these errors

在此处输入图片说明

There are various AMD libraries, some of them are systemjs, requireJS.

If you are using requireJS , you can use var FCM=require('@ionmic-native/fcm'); .

If you are using es6+ then you will get support of import keyword.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM