javascript - 未捕获的类型错误:$.number 不是函数
问题描述
我正在尝试从 api 获取服务器统计信息。后端工作,但 javascript 方面没有。我收到这个错误。
Uncaught TypeError: $.number is not a function
.
function getStats(auto=true) {
var rStart = Date.now();
if (window.rServerID == "home") {
rURL = "<?php echo site_url('index.php/api/stats'); ?>";
} else {
rURL = "<?php echo site_url('index.php/api/stats/'); ?>" ;
}
$.getJSON(rURL, function(data) {
// Open Connections
var rCapacity = Math.ceil((data.open_connections / data.total_connections) * 100);
if (isNaN(rCapacity)) { rCapacity = 0; }
$(".active-connections .entry").html($.number(data.open_connections, 0));
$(".active-connections .entry-percentage").html($.number(data.total_connections, 0));
$(".active-connections .progress-bar").prop("aria-valuenow", rCapacity);
$(".active-connections .progress-bar").css("width", rCapacity.toString() + "%");
$(".active-connections .sr-only").html(rCapacity.toString() + "%");
解决方案
我找到了解决方案。这个函数($.number)来自 jquery-number 库。 https://github.com/customd/jquery-number
谢谢你们 :)
推荐阅读
- python - 当表已经存在时,使用 spark 数据框覆盖表失败
- javascript - 如何使用 debouncetime 防止 Ionic 4 中的多次点击?
- docker - 保存 docker 镜像并在 plesk 中运行
- php - 谷歌幻灯片 php,管理共享设置
- vue.js - 在子组件中重用父组件的方法
- php - Doctrine2:左连接中的 SUM
- r - 如何通过相同的行名但按顺序连接两个数据框?
- webassembly - 为什么需要 WebAssembly?
- javascript - 如何用图像填充旋转的画布矩形
- swift - 如何在 Swift 中关闭应用程序播放音频样本时运行后台计时器