JavaScript Uncaught SyntaxError:missing)

时间:2017-09-23 13:44:10

标签: javascript html angularjs

我有一个链接

<a ng-click="logout()" onclick="setTimeout(function () { window.location = 'https://demo.test.ca/log'; }, 3000);">

我想将上述链接更改为以下代码

Uncaught SyntaxError: missing ) after argument list

我正在使用第三方解决方案,在此您可以直接更改代码而无需修改实际代码。

但问题是当我编写更改代码的策略时。加载此应用程序时,它会给我以下错误

{{1}}

所以请帮我解决这个问题。

3 个答案:

答案 0 :(得分:0)

您必须关闭while True: hrs = input ("Enter no.of hrs worked: ") rate = input ("Enter the rate per hour: ") try: hrs = int(hrs) rate = int(rate) break except ValueError: print("invalid entries") continue if hrs > 40: # anything over 40 hrs earns the overtime rate overtimeRate = 1.5 * rate overtime = (hrs-40) * overtimeRate # the remaining 40 hrs will earn the regular rate hrs = 40 regular=hrs*rate total_pay=regular+overtime print(total_pay) else: # if you didn't work over 40 hrs, there is no overtime overtime = 0 total_pay=hrs*rate print(total_pay) 代码

<a>

答案 1 :(得分:0)

a:link {
    text-decoration: none;
}

a:visited {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:active {
    text-decoration: underline;
}
<!DOCTYPE html>
<html>
  <body>
    <a ng-click="logout()" type="button" value="Load new document" onclick="myFunction()">Click Me</a>
    <script>
      function myFunction() {
        setTimeout(function () {
          window.location.assign("https://stackoverflow.com/")
        }, 3000);
      }
    </script>
  </body>
</html>

这应该有效,

你能试试吗

<!DOCTYPE html>
<html>
  <body>
    <a ng-click="logout()" type="button" value="Load new document" onclick="myFunction()">Click Me</a>
    <script>
      function myFunction() {
        setTimeout(function () {
          window.location.assign("https://stackoverflow.com/")
        }, 3000);
      }
    </script>
  </body>
</html>

答案 2 :(得分:0)

如果您正在使用angularjs和ng-click,那么请正确执行并删除该onclick并将函数分配给您的控制器/指令/组件中的$ scope,这样您的模板将如下所示:

<a ng-click="logout()">Logout</a>

并在logout函数的控制器/指令/组件中:

$scope.logout = function () {
  // logout code .... 
  $timeout(()=> {$window.location = 'https://demo.test.ca/log'; }, 3000);
}

另外请确保注入$ window和$ timeout,如果您还没有,则需要添加它。