123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <template>
- <uni-rate class="jnpf-rate" v-model="innerValue" :size="20" :max="max" :allowHalf="allowHalf" :disabled="disabled"
- @change="onChange" />
- </template>
- <script>
- export default {
- name: 'jnpf-rate',
- inheritAttrs: false,
- props: {
- modelValue: {
- type: [Number, String],
- default: 0
- },
- allowHalf: {
- type: Boolean,
- default: false
- },
- max: {
- type: Number,
- default: 5
- },
- disabled: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- modelValue: {
- handler(val) {
- this.innerValue = Number(val)
- },
- immediate: true
- }
- },
- data() {
- return {
- innerValue: 0
- }
- },
- methods: {
- onChange(data) {
- this.$emit('update:modelValue', data.value)
- this.$emit('change', data.value)
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .jnpf-rate {
- width: 100%;
- display: flex;
- justify-content: flex-end
- }
- </style>
|