gpt4 book ai didi

angular - 下面的代码可以在 Angular 8 中运行。但是我需要在 Angular 6 中执行它。我怎样才能实现这一点?

转载 作者:行者123 更新时间:2023-12-03 00:33:08 25 4
gpt4 key购买 nike

此代码可以按预期在 Angular 8 中运行:

declare var GlgToolkit: any;

import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-glg-dashboard',
templateUrl: './glg-dashboard.component.html',
styleUrls: ['./glg-dashboard.component.scss']
})
export class GlgDashboardComponent implements OnInit {
glg = new GlgToolkit();

constructor() { }

ngOnInit() {}
}

当我在 Angular 6 中使用相同的代码时,会出现错误:

ERROR Error: Uncaught (in promise): ReferenceError: GlgToolkit is not defined ReferenceError: GlgToolkit is not defined at new GlgDashboardComponent (glg-dashboard.component.ts:16) at createClass (core.js:9084) at createDirectiveInstance (core.js:8971) at createViewNodes (core.js:10191) at createRootView (core.js:10105) at callWithDebugContext (core.js:11136) at Object.debugCreateRootView [as createRootView] (core.js:10623) at ComponentFactory_.push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create (core.js:8451) at ComponentFactoryBoundToModule.push../node_modules/@angular/core/fesm5/core.js.ComponentFactoryBoundToModule.create (core.js:3265) at ViewContainerRef_.push../node_modules/@angular/core/fesm5/core.js.ViewContainerRef_.createComponent (core.js:8561) at resolvePromise (zone.js:814) at resolvePromise (zone.js:771) at zone.js:873 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:3751) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188) at drainMicroTaskQueue (zone.js:595)

最佳答案

I have solved this problem by adding below line in index.html.

  <script defer src="assets/Js/GlgToolkitCE.js"></script>

And it's working for me.

关于angular - 下面的代码可以在 Angular 8 中运行。但是我需要在 Angular 6 中执行它。我怎样才能实现这一点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59423718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com