最近,我正在玩耍,增加了angular.js动画功能,而这并不适合所需
<style> .myDiv{ width:400px; height:200px; background-color:red; } .fadeIn-setup,.fadeOut-setup { -webkit-transition: 1s linear opacity; -moz-transition: 1s linear opacity; -o-transition: 1s linear opacity; transition: 1s linear opacity; } .fadeIn-setup{ opacity:0; } .fadeOut-setup{ opacity:1; } .fadeIn-setup.fadeIn-start { opacity: 1; } .fadeOut-setup.fadeOut-start{ opacity:0; } </style> <div ng-app> <div ng-controller='ctrl'> <input type='button' value='click' ng-click='clicked()' /> <div ng-show="foo == true" class='myDiv' ng-animate="{show: 'fadeIn',hide:'fadeOut'}"> </div> </div> </div> function ctrl($scope){ $scope.foo = false; $scope.clicked = function(){ $scope.foo = !($scope.foo); } }
它在dom.ready上破坏了myDiv,并开始消失.而最初应该隐藏.如何解决?