html <div ng-class="{'enter': showElement, 'leave': !showElement}"></div> css .enter { opacity: 1; transition: opacity 0.5s; } .leave { opacity: 0; transition: opacity 0.5s; } script angular.module('myApp', ['ngAnimate']) .controller('myController', function($scope) { $scope.showElement = false; $scope.toggleElement = function() { $scope.showElement = !$scope.showElement; }; });


上一篇:
下一篇:
切换中文