(function(){
Vue.component('year-filter', {
template: '
',
props:['selectedYear',"minYear"],
data: function(){
return {
years: []
}
},
methods: {
chooseYear:function(year){
this.selectedYear = year;
},
resetClick:function(){
this.selectedYear = this.years[0];
},
confirmClick:function(){
//触发刷新
var vm = this;
Vuedals.Bus.$emit('close', {
chooseYear: vm.selectedYear,
});
}
},
mounted: function(){
//显示年份最低是2016年
var now = new Date(),
year = now.getFullYear();
var minYear = 2016
if(this.minYear){
minYear = this.minYear
}
// if(now.getMonth() >= 6){
// this.years.push(year);
// }
for(i=year; i>=minYear; i--){
this.years.push(i);
}
//如果前一个页面返回的选中的年份
if(!this.selectedYear){
this.selectedYear = this.years[i];
}
}
})
})()