How would I convert the follow TS statement
import {TNSFontIcon, fonticon} from 'nativescript-fonticon';
Into a Javascript require statement? My thought is:
TNSFontIcon = require('nativescript-fonticon’).TNSFontIcon()
But the TS statement is importing multiple things from the file...
Ideally you can write:
var package = require('nativescript-fonticon');
var TNSFontIcon = package.TNSFontIcon;
var fonticon = package.fonticon;
// and later use it as follows
var obj = new TNSFontIcon();
This assumes that nativescript-fonticon
is a commonjs package. If you're compiling the nativescript-fonticon
from TypeScript you can choose from various output formats, see: https://www.typescriptlang.org/docs/handbook/compiler-options.html
Note that require
isn't a standard JavaScript function and you need to polyfill with eg. requirejs.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments