docs: update rate demo

pull/1845/head
tangjinzhou 2020-02-22 20:15:09 +08:00
parent 88f2859658
commit 19354b0c19
4 changed files with 13 additions and 12 deletions

View File

@ -229,8 +229,7 @@ exports[`renders ./components/rate/demo/clear.md correctly 1`] = `
</svg></i></div>
</div>
</li>
</ul> allowClear: true
<br>
</ul> <span class="ant-rate-text">allowClear: true</span> <br>
<ul tabindex="0" role="radiogroup" class="ant-rate">
<li class="ant-rate-star ant-rate-star-full">
<div role="radio" aria-checked="true" aria-posinset="1" aria-setsize="5" tabindex="0">
@ -282,8 +281,7 @@ exports[`renders ./components/rate/demo/clear.md correctly 1`] = `
</svg></i></div>
</div>
</li>
</ul> allowClear: false
<br>
</ul> <span class="ant-rate-text">allowClear: false</span>
</div>
`;

View File

@ -1,6 +1,8 @@
import Rate from '..';
import focusTest from '../../../tests/shared/focusTest';
import mountTest from '../../../tests/shared/mountTest';
describe('Rate', () => {
focusTest(Rate);
mountTest(Rate);
});

View File

@ -11,10 +11,11 @@ Support set allow to clear star when click again.
```tpl
<template>
<div>
<a-rate :defaultValue="3" /> allowClear: true
<br />
<a-rate :allowClear="false" :defaultValue="3" /> allowClear: false
<a-rate :defaultValue="3" />
<span class="ant-rate-text">allowClear: true</span>
<br />
<a-rate :allowClear="false" :defaultValue="3" />
<span class="ant-rate-text">allowClear: false</span>
</div>
</template>
```

View File

@ -31,17 +31,17 @@ const Rate = {
configProvider: { default: () => ConfigConsumerProps },
},
methods: {
characterRender(node, { index }) {
const { tooltips } = this.$props;
if (!tooltips) return node;
return <Tooltip title={tooltips[index]}>{node}</Tooltip>;
},
focus() {
this.$refs.refRate.focus();
},
blur() {
this.$refs.refRate.blur();
},
characterRender(node, { index }) {
const { tooltips } = this.$props;
if (!tooltips) return node;
return <Tooltip title={tooltips[index]}>{node}</Tooltip>;
},
},
render() {
const { prefixCls: customizePrefixCls, ...restProps } = getOptionProps(this);