npm i --save nativescript-tslib
- 版本:1.9.1-r1
- GitHub: https://github.com/m-abs/nativescript-tslib
- NPM: https://npmjs.net.cn/package/nativescript-tslib
- 下载
- 昨日: 0
- 上周: 0
- 上月: 0
nativescript 的 tslib
tslib 是 TypeScript 的运行时库,包含所有 TypeScript 辅助函数。
不幸的是,仅仅导入 tslib
就会破坏 NativeScript 项目。
此插件解决了这个问题。
使用方法
安装模块
npm i --save nativescript-tslib
编辑:app/main.ts
import 'nativescript-tslib'; // <-- Add this
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScriptDynamic } from 'nativescript-angular/platform';
import { AppModule } from './app.module';
// A traditional NativeScript application starts by initializing global objects, setting up global CSS rules, creating, and navigating to the main page.
// Angular applications need to take care of their own initialization: modules, components, directives, routes, DI providers.
// A NativeScript Angular app needs to make both paradigms work together, so we provide a wrapper platform object, platformNativeScriptDynamic,
// that sets up a NativeScript application and can bootstrap the Angular framework.
platformNativeScriptDynamic().bootstrapModule(AppModule);
您可以在 tsconfig.json
中启用 importHelpers
,但如果您扩展了 native-classes,可能会破坏您的应用程序。
替代方案
您可以将 tsconfig.json
的目标设置为 es6,但这样您就不能在项目中扩展 native 类。