小编Seb*_*Seb的帖子

(单击)破坏内部*ng对于类型数组的元素,如果来自函数

plnkr我再现了一个奇怪的边缘案例.它可能取决于pixijs,或者可能取决于使用pixijs时发生的webgl.

请注意如何单击列表的所有元素,但是一旦开始使用pixijs(只需单击按钮),单击就会停止处理类型数组的元素.该奇怪的是,它仍然适用于所有其他元素.这是更奇怪的是,如果不是使用一个函数返回一个数组,它使用了直列排列,所有的作品如预期...

有任何想法吗 ?

app.component.ts

<button *ngIf="!renderer" (click)="breakIt()">break me</button> 
<span *ngIf="renderer">BROKEN</span>
Clicked: {{clicked | json}}

<h2>It breaks</h2>
<h3 *ngFor="#n of ns()" (click)="click(n)">{{n | json}}</h3>

<h2>It works</h2>
<h3 *ngFor="#n of [[2,4],'ciao',4,true]" (click)="click(n)">{{n | json}}</h3>
Run Code Online (Sandbox Code Playgroud)

app.component.html

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    templateUrl: './app/app.component.html'
})
export class AppComponent { 
  clicked = "";
  renderer;

  breakIt() {
    this.renderer = PIXI.autoDetectRenderer(200, 200,{backgroundColor : 0x1099bb});
  }

  ns() {
    return [[2,4],'ciao',4,true];
  }

  click(n) {
    this.clicked=n;  
  }
}
Run Code Online (Sandbox Code Playgroud)

angular

2
推荐指数
1
解决办法
5675
查看次数

标签 统计

angular ×1