![](/img/trans.png)
[英]Math.random() javascript function *undefined* on Chrome
[英]javascript TypeError: Math.random is not a function on chrome
我在 AngularJS 代碼中使用 Math.random() 函數
$scope.runFull = function () {
var rand;
do {
rand = Math.random();
...
} while ($scope.cond < 5400); // 90 minutes
};
$scope.runFull();
我的 Chrome 控制台返回javascript TypeError: Math.random is not a function
我把 Math 放在 watcher 中,我發現 Math.abs、Math.acos、Math....、Math.random、Math....
Math 或 Math.random 被覆蓋。 運行 Math.random() 作為您的第一行代碼,看看會發生什么。
我的錯誤是: angular.module('xxxxxApp') .controller('FullController', function ($scope, $interval, xxxxService, yyyyService, ..., Math , Principal) {
是的,非常感謝大家,我有一個名為“Math”的 angularjs 服務。
解決方案:我在“數學”中重命名我的“數學”服務,我可以使用 Math.random() :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.