支持如下属性。
名称 |
类型 |
默认值 |
是否必填 |
描述 |
|---|---|---|---|---|
id |
number |
- |
否 |
唯一标识。 |
style |
number |
- |
否 |
样式声明。 |
class |
number |
- |
否 |
引用样式表。 |
for |
array |
- |
否 |
根据数据列表,循环展开当前标签。 |
if |
boolean |
- |
否 |
根据数据boolean值,添加或移除当前标签。 |
支持如下样式。
名称 |
类型 |
默认值 |
是否必填 |
描述 |
|---|---|---|---|---|
color |
color |
rgba(0, 0, 0, 0.54) |
否 |
文本颜色。 |
font-size |
number |
30px |
否 |
文本尺寸。 |
font-style |
normal | italic |
normal |
否 |
设置字体样式。 |
font-weight |
lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | normal | bold | bolder |
normal |
否 |
字体的粗细,默认为normal。 |
text-decoration |
underline | line-through | none |
none |
否 |
对文本设置某种效果。 |
font-family(1030+) |
string |
- |
否 |
通过该属性可以设置组件中字符串的字体,支持四种系统原生字体:normal,sans-serif,serif,monospace(此四种字体只对英文有效)。 如果需要设置自定义字体,请参见“font-face样式”。 |
<template>
<div class="container">
<div class="page-title-wrap">
<text class="page-title">{{componentName}}</text>
</div>
<div class="item-container">
<text class="item-title">As a child component of text</text>
<text>
<span>I am span,</span>
<span style="color: #f76160">I am span,</span>
<span style="color: #f76160;text-decoration: underline;">I am span,</span>
<span style="color: #f76160;text-decoration: line-through;">I am span,</span>
<span style="color: #f76160;font-style: italic;">I am span,</span>
<span style="color: #f76160;font-weight: bold;">I am span,</span>
<span style="color: #f76160;font-size: 50px;">I am span.</span>
<span style="color: #f76160;font-family:serif;">I am span.</span>
</text>
<text class="item-title">As a child component of text:Style text</text>
<text style="lines: 1; text-overflow: ellipsis; color: #09ba07;">
<span>I am span,</span>
<span style="color: #f76160">I am span,</span>
<span style="color: #f76160;text-decoration: underline;">I am span,</span>
<span style="color: #f76160;text-decoration: line-through;">I am span,</span>
<span style="color: #f76160;font-style: italic;">I am span,</span>
<span style="color: #f76160;font-weight: bold;">I am span,</span>
<span style="color: #f76160;font-size: 50px;">I am span.</span>
</text>
<text class="item-title">As a child component of a</text>
<a href="https://www.huawei.com/">
<span>I am span,</span>
<span style="color: #0faeff">I am span,</span>
<span style="color: #0faeff;text-decoration: underline;">I am span,</span>
<span style="color: #0faeff;text-decoration: line-through;">I am span,</span>
<span style="color: #0faeff;font-style: italic;">I am span,</span>
<span style="color: #0faeff;font-weight: bold;">I am span,</span>
<span style="color: #0faeff;font-size: 50px;">I am span.</span>
<span style="color: #0faeff;font-family:serif;">I am span.</span>
</a>
<text class="item-title">As a child component of a:Style a</text>
<a href="https://www.huawei.com/" style="lines:1; text-overflow: ellipsis;color: #09ba07;">
<span>I am span,</span>
<span style="color: #0faeff">I am span,</span>
<span style="color: #0faeff;text-decoration: underline;">I am span,</span>
<span style="color: #0faeff;text-decoration: line-through;">I am span,</span>
<span style="color: #0faeff;font-style: italic;">I am span,</span>
<span style="color: #0faeff;font-weight: bold;">I am span,</span>
<span style="color: #0faeff;font-size: 50px;">I am span.</span>
</a>
<text class="item-title">Span nesting: as a child component of text</text>
<text>
<span>
<span>I am outer span,</span>
<span style="color: #f76160;font-size: 60px;font-weight: bold;">I am inner span,</span>
<span style="color: green;font-size: 40px;font-style: italic;">I am inner inner span;</span>
</span>
<span>
I am outer span,
<span style="color: #f76160;font-size: 60px;font-weight: bold;">
I am inner span,
<span style="color: green;font-size: 40px;font-style: italic;">I am inner inner span.</span>
</span>
</span>
</text>
<text class="item-title">Span nesting: as a child component of a</text>
<a>
<span>
<span>I am outer span,</span>
<span style="color: #f76160;font-size: 60px;font-weight: bold;">I am inner span,</span>
<span style="color: green;font-size: 40px;font-style: italic;">I am inner inner span;</span>
</span>
<span>
I am outer span,
<span style="color: #f76160;font-size: 60px;font-weight: bold;">
I am inner span,
<span style="color: green;font-size: 40px;font-style: italic;">I am inner inner span.</span>
</span>
</span>
</a>
</div>
</div>
</template>
<style>
.container {
flex: 1;
flex-direction: column;
}
.page-title-wrap {
padding-top: 50px;
padding-bottom: 80px;
justify-content: center;
}
.page-title {
padding-top: 30px;
padding-bottom: 30px;
padding-left: 40px;
padding-right: 40px;
border-color: #bbbbbb;
color: #bbbbbb;
border-bottom-width: 2px;
}
.item-container {
margin-bottom: 50px;
margin-right: 60px;
margin-left: 60px;
flex-direction: column;
}
.item-title {
padding-top: 50px;
padding-bottom: 20px;
color: #aaaaaa;
}
</style>
<script>
export default {
data: {
componentName: 'span'
},
onInit() {
this.$page.setTitleBar({ text: 'span' })
}
}
</script>
效果图如下:
