小编Iva*_*ich的帖子

笑话导入语句:“类型错误:无法将属性‘fillStyle’设置为 null”

我输入:

npm test
Run Code Online (Sandbox Code Playgroud)

我得到:

在此输入图像描述

有趣的是,导入语句在 BootScene.test.js 文件中有效,但在导入的文件中不起作用。

我关注的是在 JEst 下不起作用的导入语句。所以我想这可能与 jest 使用的 Ecma Script 版本有关。所以我尝试了这个解决方案,但错误仍然存​​在。

是这个问题的回购/分支。

当我输入npm start. 一切都进行得很快,没有任何错误。

javascript phaser-framework jestjs babeljs

10
推荐指数
2
解决办法
2万
查看次数

Angular 7:无法绑定到“指令”,因为它不是“元素”的已知属性

我试图创建一个自定义指令,但出现此错误:

在此处输入图片说明

该指令包含在@NgModule内部的声明中。尽管如此,仍无法正常工作。如果您需要有关错误的更多信息,请询问。我不知道这是怎么回事。

app.component.html

<input class="text" [appInputFormat]>
Run Code Online (Sandbox Code Playgroud)

输入格式指令

[![import { Directive, HostListener } from '@angular/core';

@Directive({
  selector: '[appInputFormat]'
})
export class InputFormatDirective {

    constructor(){};

  @HostListener('focus')  onFocus(){
    console.log('on Focus');
  }
  @HostListener('blur')  onBlur(){
    console.log('on Blur');
  }
}
Run Code Online (Sandbox Code Playgroud)

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule} from '@angular/forms';



import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CourseComponent } from './course/course.component';
import { FavoriteComponent } from './favorite/favorite.component';
import { PanelComponent } …
Run Code Online (Sandbox Code Playgroud)

angularjs-directive angular

4
推荐指数
1
解决办法
2861
查看次数

错误TypeError:_co.function不是函数

这是我在尝试使子代调用父代的方法时遇到的错误:

在此处输入图片说明

孩子是最喜欢的组件。该方法onFavoriteChange()存在于父级中,但未触发。

app.component.ts

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

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {
  title = 'Ivans-world';
  post = {
    title:"Titulo",
    isFavorite: true
  }

  OnFavoriteChange(){  
    console.log("App Component. Triggered OnChanges(). Yupi!");
  }

}
Run Code Online (Sandbox Code Playgroud)

app.component.html

<favorite   
       [is-favorite] = "post.isFavorite"  
       (change)  = "onFavoriteChange()"  
></favorite>
Run Code Online (Sandbox Code Playgroud)

最喜欢的组件

import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { empty } from 'rxjs';

@Component({
  selector: 'favorite',
  templateUrl: './favorite.component.html',
  styleUrls: ['./favorite.component.css'],
})
export class FavoriteComponent implements OnInit …
Run Code Online (Sandbox Code Playgroud)

angular

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