update Rate

update Rate @huixisheng
This commit is contained in:
梁灏 2017-03-03 11:00:11 +08:00
parent 743d027897
commit e2c6ff2b67
3 changed files with 19 additions and 51 deletions

View file

@ -48,15 +48,9 @@
hoverIndex: -1, hoverIndex: -1,
isHover: false, isHover: false,
isHalf: false, isHalf: false,
currentValue: 0 currentValue: this.value
}; };
}, },
// created () {
// this.currentValue = this.value;
// this.setHalf(this.currentValue);
// },
mounted () {
},
computed: { computed: {
classes () { classes () {
return [ return [
@ -68,26 +62,12 @@
} }
}, },
watch: { watch: {
value: { value (val) {
immediate: true, this.currentValue = val;
handler (val) {
this.currentValue = val;
}
}, },
// valur (val) { currentValue (val) {
// console.log(val); this.setHalf(val);
// this.currentValue = val;
// console.log(this.currentValue);
// },
currentValue: {
immediate: true,
handler () {
this.setHalf(this.currentValue);
}
} }
// currentValue () {
// this.setHalf(this.currentValue);
// }
}, },
methods: { methods: {
starCls (value) { starCls (value) {
@ -138,13 +118,13 @@
}, },
handleClick (value) { handleClick (value) {
if (this.disabled) return; if (this.disabled) return;
// value++; // value++;
if (this.isHalf) value -= 0.5; if (this.isHalf) value -= 0.5;
this.currentValue = value; this.currentValue = value;
this.$emit('on-change', this.currentValue); this.$emit('input', value);
this.$emit('input', this.currentValue); this.$emit('on-change', value);
// @todo // @todo
// this.$dispatch('on-form-change', value); // this.$dispatch('on-form-change', value);
} }
} }
}; };

View file

@ -30,14 +30,14 @@
import Icon from '../icon/icon.vue'; import Icon from '../icon/icon.vue';
import Checkbox from '../checkbox/checkbox.vue'; import Checkbox from '../checkbox/checkbox.vue';
import { t } from '../../locale'; import { t } from '../../locale';
import emitter from '../../mixins/emitter'; import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-tree'; const prefixCls = 'ivu-tree';
export default { export default {
name: 'Tree', name: 'Tree',
components: { Icon, Checkbox }, components: { Icon, Checkbox },
mixins: [ emitter ], mixins: [ Emitter ],
props: { props: {
value: { value: {
type: Array, type: Array,

View file

@ -1,30 +1,18 @@
<template> <template>
<Row> <div>
<i-col span="12"> <Rate v-model="v1" allow-half show-text disabled>
<Rate show-text :value="valueText"></Rate> <span style="color: #f5a623">{{ v1 }}</span>
</i-col> </Rate>
<i-col span="12"> {{ v1 }}
<Rate show-text v-model="valueCustomText" > <div @click="v1 = 3">change v1</div>
<span style="color: #f5a623">{{ valueCustomText }}</span> </div>
</Rate>
</i-col>
<i-col span="12">
<Rate disabled :value="valueDisabled"></Rate>
</i-col>
<i-col span="12">
<Rate allow-half :value="valueHalf" v-on:on-change="changeValue"></Rate>
</i-col>
</Row>
</template> </template>
<script> <script>
export default { export default {
props: {}, props: {},
data () { data () {
return { return {
valueText: 3, v1: 2
valueCustomText: 3.8,
valueDisabled: 2,
valueHalf: 2.5
}; };
}, },
computed: {}, computed: {},