(function(){
Vue.component('year-filter', {
template: '
',
props:['selectedYear'],
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();
if(now.getMonth() >= 6){
this.years.push(year);
}
for(i=year-1; i>=2016; i--){
this.years.push(i);
}
//如果前一个页面返回的选中的年份
if(!this.selectedYear){
this.selectedYear = this.years[i];
}
}
})
})()