如何在 Nativescript App 的 package.json 中加载 CDN 作为依赖项?

问题描述

我有 Nativescript+Angular 应用程序,我想在其中加载有助于加载播放器的外部 CDN。 如何实现这一目标?有没有办法在 package.json 的依赖项部分加载 URL/CDN?

我问这个是因为 NativeScript 中没有 index.html。如果有像 Angular 应用程序一样的 index.html,那么我可以像下面这样调用 CDN:-

<head>
<script src="CDN_URL_Here"></script>
</head>

我想在这里解释一下我的方法。希望有帮助。

package.json

{
"dependencies": {
   "@angular/animations": "~8.2.0","@angular/common": "~8.2.0","@angular/compiler": "~8.2.0","nativescript-player": "CDN_URL_Here"
}
}

app.component.ts

import { registerElement,RouterExtensions } from "@nativescript/angular";
registerElement('vidplayer',() => require('nativescript-player'))

sample.component.html

<GridLayout>
    <vidplayer [src]="src"></vidplayer>
</GridLayout>

sample.component.ts

export class VidComponent {
    constructor() {
       this.src.url = "VIDEO_URL_HERE"
    }
}

请告诉我正确的方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...