You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/rate/demo/index.vue

72 lines
1.5 KiB

7 years ago
<template>
<div>
基本
<Rate class="custom"></Rate>
</br>
半星
<Rate :allowHalf="allowHalf"></Rate>
</br>
默认3颗星
<Rate v-model="initValue"></Rate>
<AntButton type="primary" @click="changeValue"></AntButton>
<AntButton type="primary" @click="getValue"></AntButton>
</br>
只读
<Rate :value="initValue" :disabled="disabled"></Rate>
</br>
回调函数
<Rate
7 years ago
@change="onChange"
@hover-change="onHoverChange"></Rate>
7 years ago
<span v-if="hoverValue">{{hoverValue}}stars</span>
<span v-if="rValue">{{rValue}}stars</span>
<br/>
<Rate
:allowHalf="allowHalf"
7 years ago
@hover-change="onHoverChangeAH"></Rate>
7 years ago
<span v-if="hoverValueAH">{{hoverValueAH}}stars</span>
</br>
自定义
<Rate :value="initValue" :allowHalf="allowHalf" :character="character"></Rate>
</div>
</template>
<script>
import '../style'
import { Rate, Icon, Button } from 'antd/index'
export default {
data () {
return {
allowHalf: true,
initValue: 3,
disabled: true,
hoverValue: undefined,
rValue: undefined,
hoverValueAH: undefined,
character: '好',
}
},
methods: {
onHoverChange (val) {
this.hoverValue = val
},
onChange (val) {
this.rValue = val
},
onHoverChangeAH (val) {
this.hoverValueAH = val
},
changeValue () {
this.initValue = 4
7 years ago
},
getValue () {
console.log(this.initValue)
},
},
components: {
Rate,
Icon,
AntButton: Button,
},
}
</script>