12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- export default (injectName) => {
- return {
- inject: [injectName],
- props: {
- value: { type: Number, default: 1 },
- size: {
- type: String,
- default: 'small',
- validator(value) {
- const validSizes = ['medium', 'small', 'mini']
- const isValid = validSizes.includes(value) || value === ''
- if (!isValid) {
- console.warn(`Invalid prop: size should be one of 'medium', 'small', or 'mini', but received '${value}'.`)
- }
- return isValid
- }
- }
- },
- data() {
- return {
- selectValue: 1
- }
- },
- watch: {
- value: {
- handler(newValue, oldValue) {
- if (newValue !== oldValue) {
- this.selectValue = newValue
- }
- },
- immediate: true
- },
- selectValue: {
- handler(newValue, oldValue) {
- if (newValue !== oldValue) {
- this.$emit('input', newValue)
- }
- }
- }
- }
- }
- }
|