【发布时间】:2016-07-27 11:40:21
【问题描述】:
如何从 videogular2 导入 videogular2 控件,覆盖播放模块,因为它没有 index.js 或 videogular.js 文件。 我尝试了以下代码:
npm install videogular2
但在 videogular2 节点模块中找不到 videogular2.js 或 index.js。
【问题讨论】:
标签: angular
如何从 videogular2 导入 videogular2 控件,覆盖播放模块,因为它没有 index.js 或 videogular.js 文件。 我尝试了以下代码:
npm install videogular2
但在 videogular2 节点模块中找不到 videogular2.js 或 index.js。
【问题讨论】:
标签: angular
导入这些解决了我的问题
import { VgCoreModule } from 'videogular2/compiled/core';
import { VgControlsModule } from 'videogular2/compiled/controls';
import { VgOverlayPlayModule } from 'videogular2/compiled/overlay-play';
import { VgBufferingModule } from 'videogular2/compiled/buffering';
【讨论】:
videogular2的主文件是core.js,不是index.js。您必须将它与 controls.js 和 overlay-play.js 一起导入,它们都可以在根目录中找到。
如果您使用的是 angular-cli,以下是对我有用的配置:
angular-cli-build.js
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
...
'videogular2/dist/**/*',
'videogular2/core.+(ts|js)',
'videogular2/controls.+(ts|js)',
'videogular2/overlay-play.+(ts|js)'
...
]
});
};
system-config.ts
const map: any = {
...
'videogular2': 'vendor/videogular2'
...
};
const packages: any = {
...
'videogular2': {
main: 'core.js'
}
...
};
在你的 angular2 类中,你可以按如下方式导入它:
import { VgPlayer } from 'videogular2/core';
import { VgControls } from 'videogular2/controls';
--
最后,我遇到了一个缺少 VgAPI 提供程序的问题。
在我的 angular2 组件中,我必须执行以下操作:
import { VgAPI } from 'videogular2/core';
@Component({
...
providers: [
VgAPI
]
...
})
class MyComponent { }
【讨论】:
添加这个库。在 angular-cli-build.js 中
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
...
'videogular2/**/*',
...
]
});
};
【讨论】:
我遇到了同样的问题,但 @Apharanes 和 @Sureshreddy 的解决方案对我无效。我没有名为 angular-cli-build.js 的文件。
解决方案非常简单。它只是意味着在安装中添加“--save”:
npm install videogular2 --save
我在执行“npm list videogular”时发现了它。它给了我一个“无关的”错误。查看此错误告诉我,我已经安装了该软件包,但由于它不存在于我的 package.json 中,因此它认为它是“无关的”。
【讨论】:
对我来说,这是节点版本的问题。 videogular 的最新版本(今天为 7.0.1)仅支持节点版本 >= 10:
他们的 package.json 的提取:
"engines": {
"node": ">=10.9.0 <11.0.0"
},
您可以使用以前版本的 videogular (6.4.0) 或更新节点的版本。
【讨论】: