使用@HostBindings代替以角度4托管 [英] Use @HostBindings instead host in angular 4

查看:78
本文介绍了使用@HostBindings代替以角度4托管的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是尝试制作带有角度4的动画,并且看到了在组件中使用宿主的教程

  import {组件,来自@@ angular / core的OnInit,HostBinding}; 
从 angularfire2导入{AngularFire,AuthProviders,AuthMethods};
从 @ angular / router导入{Router};
从 ../router.animations导入{moveIn};

@Component({
选择器:'app-login',
templateUrl:'./login.component.html',
styleUrls:['./ login.component.css'],
动画:[moveIn()],
主机:{'[@ moveIn]':''}
})

但它显示了主机属性
下的错误 [tslint]使用@hostBindings和@HostListeners代替主机属性

解决方案

tslint 并非错误。它们是由tslint Webpack服务创建的TypeScript linting消息。



您可以在此处阅读有关TSLint的更多信息:



https://palantir.github.io/tslint/



由于某种原因,有人认为在组件中使用 host 属性是一种不好的做法。您完全可以使用该功能以及其他组件配置功能。<​​/ p>

要禁用此皮棉检查,请编辑您的 tslint.json 文件并添加/修改以下内容:

  use-host-property-decorator:false 

将其设置为 false 会禁用该检查。


I just try to make animation with angular 4 and I saw tutorial that use host in the component

import { Component, OnInit, HostBinding } from '@angular/core';
import { AngularFire, AuthProviders, AuthMethods } from 'angularfire2';
import { Router } from '@angular/router';
 import { moveIn } from '../router.animations';

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

but it shows me error under the host property "[tslint] use @hostBindings and @HostListeners instead of the host property"

解决方案

tslint are not errors. They are TypeScript linting messages created by the tslint webpack service.

You can read more on TSLint here:

https://palantir.github.io/tslint/

For some reason, someone decided that using the host property in a component was a bad practice. You're perfectly fine to use that feature, and the other component configuration features.

To disable this lint check edit your tslint.json file and add/modify the following:

    "use-host-property-decorator": false

Setting it to false disables the check.

这篇关于使用@HostBindings代替以角度4托管的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆