You need to sign in or sign up before continuing.
提交 c992260b 编写于 作者: Y yaoyuchi

修改检视意见

Signed-off-by: Nyaoyuchi <yaoyuchi@huawei.com>
上级 5d1da65b
# 继承样式
> **说明:**
# 继承样式 <sup>9+</sup>
> ![icon-note.gif](D:/git/doc/docs/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-note.gif) **说明:**
> 从api version 9开始支持。 > 从api version 9开始支持。
自定义组件具有inhert-class属性,定义如下: 自定义组件具有inhert-class属性,定义如下:
| 名称 | 类型 | 默认值 | 必填 | 描述 | | 名称 | 类型 | 默认值 | 必填 | 描述 |
| ------------------------- | ------ | ------ | ---- | ------------------------------------------------------ | | ------------ | ------ | ------ | ---- | ------------------------------------------------------ |
| inhert-class<sup>9+</sup> | string | - | 否 | 从父组件继承的class样式,多个class样式之间用空格分隔。 | | inhert-class | string | - | 否 | 从父组件继承的class样式,多个class样式之间用空格分隔。 |
可以通过设置inhert-calss属性来继承父组件的样式,代码示例如下: 可以通过设置inhert-calss属性来继承父组件的样式
自定义组件的hml文件,其中fatherclass1和fatherclass2是从父组件继承的样式。 自定义组件的hml文件,其中fatherclass1和fatherclass2是从父组件继承的样式。
```html ```html
<!--comp.hml--> <!--comp.hml-->
<div class="item"> <div class="item">
...@@ -23,10 +19,7 @@ ...@@ -23,10 +19,7 @@
</div> </div>
``` ```
父页面的hml文件,其中comp自定组件通过inhert-class属性,继承了父组件的fatherclass1和fatherclass2样式。 父页面的hml文件,其中comp自定组件通过inhert-class属性,继承了父组件的fatherclass1和fatherclass2样式。
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<element name='comp' src='../../common/component/comp.hml'></element> <element name='comp' src='../../common/component/comp.hml'></element>
...@@ -36,10 +29,7 @@ ...@@ -36,10 +29,7 @@
</div> </div>
``` ```
父页面的css文件 父页面的css文件
```html ```html
// xxx.css // xxx.css
.fatherclass1 { .fatherclass1 {
...@@ -51,9 +41,3 @@ ...@@ -51,9 +41,3 @@
border:2px; border:2px;
} }
``` ```
\ No newline at end of file
<div class="container">
<comp title="自定义组件" inhert-class="fatherclass1" ></comp>
</div>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册