js 年份左右点击加减

时间:2021-08-29 20:40:32
            默认为今年
            var date = new Date;
            $scope.year = date.getFullYear();
            //年份减
            $scope.yearPrev = function(){
                $scope.year -- ;
                if($scope.year == 1999){
                    showTips('超出选择范围!');
                    $scope.year ++;
                }
            }
            //年份加
            $scope.yearNext = function(){
                $scope.year ++;
                if($scope.year == 2031){
                    showTips('超出选择范围!');
                    $scope.year --;
                }
            };