sirirus-master 2019-12-21 21:42 采纳率: 0%
浏览 511

angularjs报错:XXX.inject is not a function

查了一圈,网上都是其他的XXX is not a function,他们的说是根模块禁止$监听
我在制作图片滚播时,在vscode里不会报错,但是在chrome里开发者工具提示我如下错误,并且图片也是竖直排列,并没有轮播。

backend.js:32708 Uncaught TypeError: rootNgProbe.inject is not a function
at Angular2Adapter._trackAngularChanges (backend.js:32708)
at Angular2Adapter.setup (backend.js:32704)
at Object. (backend.js:33421)
at webpack_require (backend.js:20)
at Object. (backend.js:47)
at webpack_require (backend.js:20)
at backend.js:40
at backend.js:43

代码片段如下:
css:

.container {
    position: relative;
    overflow: hidden;
}

.container.image-slider {
    display: flex;
    overflow-x: scroll;
}

.nav-section {
    position: absolute;
    bottom: 0;
    width: 100%;
    opacity: 0.5;
    color: #fff;
    background-color: #000;
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
}

.nav-section.slide-button {
    display: flex;
    width: 10px;
    height: 10px;
    background-color: #fff;
    text-decoration: none;
    border-radius: 50%;
    margin: 5px;
}

html:

<div class="container">
    <div class="image-slider">
        <img *ngFor="let slider of sliders"  [src]="slider.imgUrl" [alt]="slider.caption">
    </div>
    <div class="nav-section">
        <span *ngFor="let _ of sliders; let idx = index" class="slide-button">

        </span>
    </div>
</div>

ts:

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

export interface ImageSlider {
  imgUrl: string;
  link: string;
  caption: string;
}

@Component({
  selector: 'app-image-slider',
  templateUrl: './image-slider.component.html',
  styleUrls: ['./image-slider.component.css']
})
export class ImageSliderComponent implements OnInit {

  @Input() sliders: ImageSlider[] = [];
  constructor() { }

  ngOnInit() {
  }

}

  • 写回答

1条回答

  • threenewbee 2019-12-21 23:12
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能