const Months = { template: ` {{ item.name }} `, props: { value: { type: [String,Array], defatut: '' }, id: { type: String, default: '' }, mode: { type: String, default: 'default' }, disabled: { type: Boolean, default: false }, placeholder:{ type: String, default: '请选择月份' } }, data() { return { defaultVal: this.value, monthList: [] }; }, mounted() { const year = new Date().getFullYear() const curMonth = new Date().getMonth() const m = ['一','二','三','四','五','六','七','八','九','十','十一','十二'] for(let i=1;i<=12;i++){ this.monthList.push({ val: year +"-" + (i<10?'0'+i:i), name: year + '年' + (i<10?'0'+i:i) + '月', disabled: (i-1)>curMonth }) } }, watch: { value(newValue, oldValue) { this.defaultVal = newValue }, }, methods: { filterOption (input, option) { return ( option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ) }, handleChange(value) { this.defaultVal = value; const row = this.monthList.find(item => item.val == value) this.$emit('input', value); this.$emit('change', value, this.id, row); }, }, }; export default Months