ant-design-vue/examples/rate.vue

71 lines
1.6 KiB
Vue
Raw Normal View History

2017-11-01 09:03:42 +00:00
<template>
<div>
基本
2017-11-02 07:05:31 +00:00
<Rate class="custom"></Rate>
2017-11-01 09:03:42 +00:00
</br>
半星
<Rate :allowHalf="allowHalf"></Rate>
</br>
默认3颗星
2017-11-02 02:56:18 +00:00
<Rate v-model="initValue"></Rate>
<AntButton type="primary" @click="changeValue"></AntButton>
<AntButton type="primary" @click="getValue"></AntButton>
2017-11-01 09:03:42 +00:00
</br>
只读
<Rate :value="initValue" :disabled="disabled"></Rate>
</br>
回调函数
<Rate
:onChange="onChange"
:onHoverChange="onHoverChange"></Rate>
<span v-if="hoverValue">{{hoverValue}}stars</span>
<span v-if="rValue">{{rValue}}stars</span>
<br/>
<Rate
:allowHalf="allowHalf"
:onHoverChange="onHoverChangeAH"></Rate>
<span v-if="hoverValueAH">{{hoverValueAH}}stars</span>
</br>
自定义
2017-11-03 03:08:46 +00:00
<Rate :value="initValue" :allowHalf="allowHalf" :character="character"></Rate>
2017-11-01 09:03:42 +00:00
</div>
</template>
<script>
2017-11-02 02:56:18 +00:00
import { Rate, Icon, Button } from '../components/index'
2017-11-01 09:03:42 +00:00
export default {
data () {
return {
allowHalf: true,
initValue: 3,
disabled: true,
hoverValue: undefined,
rValue: undefined,
hoverValueAH: undefined,
2017-11-02 07:05:31 +00:00
character: '好',
2017-11-01 09:03:42 +00:00
}
},
methods: {
2017-11-02 07:05:31 +00:00
onHoverChange (val) {
this.hoverValue = val
2017-11-01 09:03:42 +00:00
},
2017-11-02 07:05:31 +00:00
onChange (val) {
this.rValue = val
2017-11-01 09:03:42 +00:00
},
2017-11-02 07:05:31 +00:00
onHoverChangeAH (val) {
this.hoverValueAH = val
2017-11-02 02:56:18 +00:00
},
2017-11-02 07:05:31 +00:00
changeValue () {
this.initValue = undefined
},
getValue () {
console.log(this.initValue)
2017-11-02 02:56:18 +00:00
},
2017-11-01 09:03:42 +00:00
},
components: {
2017-11-02 02:56:18 +00:00
Rate,
Icon,
AntButton: Button,
2017-11-01 09:03:42 +00:00
},
}
</script>