javascript类型错误:随机不是chrome上的功能

javascript TypeError: Math.random is not a function on chrome

本文关键字:chrome 功能 类型 错误 随机 javascript      更新时间:2023-09-26

我在AngularJS代码中使用Math.random()函数

$scope.runFull = function () {
var rand;
    do {
        rand = Math.random();
        ...
    } while ($scope.cond < 5400); // 90 minutes         
};
$scope.runFull();

我的Chrome控制台返回javascript TypeError: Math。

我把Math放到watcher中,我找到了Math。abs、数学。这些"可信赖医疗组织"、数学……、数学。随机的,数学…

数学或数学。随机被重写了。运行Math.random()作为第一行代码,看看会发生什么。

我的错误是: angular.module('xxxxxApp').controller('FullController', function ($scope, $interval, xxxxService, yyyyService,…), 数学,校长){

是的,非常感谢大家,我有一个名为"Math"的angularjs服务。

解决方案:我将我的"Math"服务重命名为"mathematical",我可以使用Math.random():)