diff --git a/examples/docs/en-US/tag.md b/examples/docs/en-US/tag.md index 5d1da7862..10c7001df 100644 --- a/examples/docs/en-US/tag.md +++ b/examples/docs/en-US/tag.md @@ -34,7 +34,7 @@ Used for marking and selection. ### Basic usage -::: demo Use the `type` attribute to define Tag's type. +::: demo Use the `type` attribute to define Tag's type. In addition, the `color` attribute can be used to set the background color of the Tag. ```html Tag One @@ -93,6 +93,7 @@ Used for marking and selection. | closable | whether Tab can be removed | boolean | — | false | | close-transition | whether the removal animation is disabled | boolean | — | false | | hit | whether Tag has a highlighted border | boolean | — | false | +| color | background color of the tag | string | — | — | ### Events diff --git a/examples/docs/zh-CN/tag.md b/examples/docs/zh-CN/tag.md index 20b1ea444..f7071ff07 100644 --- a/examples/docs/zh-CN/tag.md +++ b/examples/docs/zh-CN/tag.md @@ -34,7 +34,7 @@ ### 基础用法 -:::demo 由`type`属性来定义,该属性可选填。 +:::demo 由`type`属性来选择tag的类型,也可以通过`color`属性来自定义背景色。 ```html 标签一 @@ -93,6 +93,7 @@ | closable | 是否可关闭 | boolean | — | false | | close-transition | 是否禁用关闭时的渐变动画 | boolean | — | false | | hit | 是否有边框描边 | boolean | — | false | +| color | 背景色 | string | — | — | ### Events diff --git a/packages/tag/src/tag.vue b/packages/tag/src/tag.vue index 40239c0de..e0b7eae84 100644 --- a/packages/tag/src/tag.vue +++ b/packages/tag/src/tag.vue @@ -2,7 +2,8 @@ + :class="[type ? 'el-tag--' + type : '', {'is-hit': hit}]" + :style="{backgroundColor: color}"> { }, true); expect(vm.$el.classList.contains('md-fade-center')).to.be.false; }); + + it('color', () => { + vm = createVue({ + template: ` + + ` + }, true); + expect(vm.$el.style.backgroundColor).to.equal('rgb(0, 0, 0)'); + }); });