博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Angular 2] Style Angular 2 Components
阅读量:6984 次
发布时间:2019-06-27

本文共 917 字,大约阅读时间需要 3 分钟。

Each Angular 2 Component can have its own styles which will remained contained inside the component. These isolated styles allow you to add whichever styles you want without worrying about them leaking out and affecting the rest of your application.

 

import {Component, Input} from "@angular/core";@Component({    selector: 'widget-one',    styles:[`:host{    display: block;    border: 3px dashed black;    font-family: "Times New Roman";}`],    template: `

One's message:

{
{message}}

`})export class WidgetOne{ @Input() message;}

 

 

Notice three things:

1. If you want to apply style to 'widget-one' tag, which means the host element for the component, you need to use ':host'.

2. The style apply only has affect to this component, won't have any effect to other component.

3. The host component doesn't have any 'display' attr setup, so you need to set it as 'flexbox' or 'block', or any other display prop....

转载地址:http://ovjpl.baihongyu.com/

你可能感兴趣的文章
微服务,微架构[一]之springboot[helloWorld]
查看>>
MySql导入CSV文件或制表符分割的文件
查看>>
《机器学习与R语言(原书第2版)》一1.2 机器学习的使用与滥用
查看>>
Android Monkey原理探讨
查看>>
PostgreSQL 10.0 preview 功能增强 - 老板特性, LONG SQL过程可视 pg_stat_progress_vacuum
查看>>
微服务架构是什么
查看>>
AngularJS 自定义服务
查看>>
proxy 动态代理
查看>>
KanaPHP框架介绍
查看>>
VectorDrawable与AnimatedVectorDrawable
查看>>
C语言OJ项目参考(2569)统计字符串种类
查看>>
用线性回归无编码实现文章浏览数预测
查看>>
视觉设计-CRUD
查看>>
服务器散热问题老大难!液体降温冷却方式你试过了吗?
查看>>
paxos算法证明过程
查看>>
如何把数据从 Mysql 导入到 Greenplum
查看>>
MongoDB Secondary同步慢问题分析
查看>>
mysql主主同步
查看>>
Gps坐标转换成gcj 02坐标的js代码
查看>>
换绑中交互的注意事项
查看>>