繁体   English   中英

ngStyle对象表达属性angular 2的多个值

[英]ngStyle object expression multiple values for property angular 2

是否可以在ngStyle指令的属性中添加多个值? 例如:

<div [ngStyle]='{"background" : ["rgba(248,80,50,1)", "-webkit-gradient(left top, right top, color-stop(0%, rgba(248,80,50,1)), color-stop(50%, rgba(241,111,92,1)), color-stop(51%, rgba(246,41,12,1)), color-stop(71%, rgba(240,47,23,1)), color-stop(100%, rgba(231,56,39,1)))"]}' ></div>

谢谢

在此示例中,您不能只使用自定义类吗? 在组件定义中,您可以使用styleUrls为该特定组件包括唯一的样式表。 例:

@Component({
selector: 'my-component',
moduleId: module.id,
templateUrl: 'my-component.html',
styleUrls: ['my-component.css'] // <-- here
})

如果您还需要切换其他样式,则使用ngClass的另一种方法可能会更容易。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM