ant-design-vue/components/rate/demo/index.vue

79 lines
1.7 KiB
Vue
Raw Normal View History

2017-11-03 09:10:38 +00:00
<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
2017-11-09 09:24:00 +00:00
@change="onChange"
@hover-change="onHoverChange"></Rate>
2017-11-03 09:10:38 +00:00
<span v-if="hoverValue">{{hoverValue}}stars</span>
<span v-if="rValue">{{rValue}}stars</span>
<br/>
<Rate
:allowHalf="allowHalf"
2017-11-09 09:24:00 +00:00
@hover-change="onHoverChangeAH"></Rate>
2017-11-03 09:10:38 +00:00
<span v-if="hoverValueAH">{{hoverValueAH}}stars</span>
</br>
自定义
2017-12-13 09:58:05 +00:00
</br>
<Rate v-model="initValue" :allowHalf="allowHalf">
<Icon type="heart" />
</Rate>
</br>
2017-12-28 10:46:31 +00:00
<Rate :defaultValue="initValue" :allowHalf="allowHalf" character="A"></Rate>
2017-12-13 09:58:05 +00:00
</br>
<Rate :value="initValue" character="好"></Rate>
2017-11-03 09:10:38 +00:00
</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 () {
2017-11-09 10:57:34 +00:00
this.initValue = 4
2017-11-03 09:10:38 +00:00
},
getValue () {
console.log(this.initValue)
},
},
components: {
Rate,
Icon,
AntButton: Button,
},
}
</script>