首页 文章

无法使用NativeScript Angular-2项目访问本机API(iOS或Android)

提问于
浏览
1

如何复制:

tns创建Something -ng
cd东西

现在关注此链接https://docs.nativescript.org/angular/core-concepts/accessing-native-apis-with-javascript.html

npm install tns-platform-declarations --save-dev

替换了tsconfig.json和reference.d.ts的内容

tns运行iOS

我越来越

file:///app/tns_modules/@angular/compiler/bundles/compiler.umd.js:18646:26:JS ERROR错误:无法解析ItemsComponent的所有参数:(?) .

ts版本2.1.6
xcode版本8.2.1
"tns-platform-declarations":"^2.5.0",
"tns-ios":{"version":"2.5.0"}
"nativescript-angular":"1.4.0",

没有这些修改,iOS项目按预期运行 .

我觉得它有引用的东西,但我不确定 .

1 回答

  • 4

    在Angular-2启用的项目中工作时,需要处理一些与DOM相关的类型 . 这将在nativescript-dev-typescript的下一版本中处理,但同时,在references.d.t.s中使用以下内容 .

    // <reference path="./node_modules/tns-core-modules/tns-core-modules.es2016.d.ts" />
    
    /// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
    /// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
    
    declare type Comment = any;
    declare type CloseEvent = any;
    declare type Document = any;
    declare type DocumentFragment = any;
    declare type Element = any;
    declare type History = any;
    declare type HTMLAnchorElement = any;
    declare type HTMLCollection = any;
    declare type HTMLDocument = any;
    declare type HTMLElement = any;
    declare type HTMLInputElement = any;
    declare type HTMLScriptElement = any;
    declare type HTMLStyleElement = any;
    declare type KeyboardEvent = any;
    declare type Location = any;
    declare type MessageEvent = any;
    declare type MouseEvent = any;
    declare type Node = any;
    declare type NodeList = any;
    declare type Text = any;
    declare type WebSocket = any;
    

    基于this application

相关问题