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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题