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 .
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.