我尝试按降序显示计时器和倒数计时器从59秒到0秒,并在计数完成后显示警告消息。但是在显示倒计时时出现问题,即在 0:1 秒之前显示警告消息。任何人都可以帮助解决此问题。
代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
</style>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp',[])
app.controller('MyController',function($scope,$window,$timeout){
var tim;
$scope.totalsec = 60;
var countdowntime= function(){
$scope.totalsec--;
$scope.min = parseInt($scope.totalsec / 60, 10);
$scope.sec = $scope.totalsec - ($scope.min * 60);
if($scope.sec >0){
tim = $timeout(countdowntime, 1000);
} else if($scope.sec ==0){
$timeout.cancel(tim);
$window.alert("Time Up");
}
};
countdowntime();
});
</script>
<div ng-app="MyApp" ng-controller="MyController">
countertime:{{min}}:{{sec}}
</div>
</body>
</html>
答案 0 :(得分:0)
if($scope.sec >0){
应该是:
if($scope.sec ==0){
所以“1”不会解雇它。 “1”大于“0”。
答案 1 :(得分:0)
试试这个:
Exception thrown: 'Mono.Data.Sqlite.SqliteException' in Mono.Data.Sqlite.dll
Additional information: SQLite error
near "WHERE": syntax error