2017-11-01 09:03:42 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
基本
|
2017-11-02 02:56:18 +00:00
|
|
|
<Rate className="custom" :allowHalf="allowHalf"></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-02 02:56:18 +00:00
|
|
|
<Rate :value="initValue" :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 02:56:18 +00:00
|
|
|
character: '好'
|
2017-11-01 09:03:42 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onHoverChange(val) {
|
|
|
|
this.hoverValue = val;
|
|
|
|
},
|
|
|
|
onChange(val) {
|
|
|
|
this.rValue = val;
|
|
|
|
},
|
|
|
|
onHoverChangeAH(val) {
|
|
|
|
this.hoverValueAH = val;
|
2017-11-02 02:56:18 +00:00
|
|
|
},
|
|
|
|
changeValue() {
|
|
|
|
this.initValue = 4;
|
|
|
|
},
|
|
|
|
getValue() {
|
|
|
|
alert(this.initValue)
|
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>
|