大佬教程收集整理的这篇文章主要介绍了typescript – Angular2 @HostBinding无法绑定背景图像样式,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@HostBinding
将属性绑定到组件的背景图像时,在指定图像URL时它不起作用.
Angular2 RC-1的第一个例子:
import {Component,HostBinding} from "@angular/core"; @Component({ SELEctor: 'demo',template: 'something' }) export class DemoComponent { @HostBinding('style.BACkground-image') BACkgroundImage = 'url(http://placekitten.com/g/200/300)'; }
在检查DOM时,我们可以找到< demo>的东西< / demo> – >不好
第二个例子:
import {Component,template: 'something' }) export class DemoComponent { @HostBinding('style.BACkground-image') BACkgroundImage = 'none'; }
这一次,在检查DOM时,我们可以找到< demo style =“BACkground-image:none;”> something< / demo> – >好
我尝试使用背景而不是背景图像,它使用的颜色类似于“蓝色”,但仍然无法使用URl.
我还尝试使用NgAfterViewInit()中的setTimeout动态更改值,当从“none”更改为“blue”时它起作用,但不是使用URL,值保持“none”.
看到这个问题:
> https://github.com/angular/angular/issues/8491
> https://github.com/angular/angular/issues/8514(修复)
以上是大佬教程为你收集整理的typescript – Angular2 @HostBinding无法绑定背景图像样式全部内容,希望文章能够帮你解决typescript – Angular2 @HostBinding无法绑定背景图像样式所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。