嗨,我正在尝试在我的网站中实现 firebase 实时数据库 API,我正在遵循以下文档:https://firebase.google.com/docs/database/admin/save-data#node.js,但我收到此错误:这是我的代码: <script type="module">// Import the functions you need from the SDKs you
2022-06-13
我尝试在 JavaScript 中打印一个整数,并使用逗号作为千位分隔符。例如,我想将数字 1234567 显示为“1,234,567”。我该怎么做呢?下面是我的做法:function numberWithCommas(x) {x = x.toString();var pattern = /(-?\d+)(\d{3})/;while (pattern.test(x))x = x.replace(p
2010-05-24
如何在 IE、Firefox 和 Chrome 中检测 Esc 键按下情况?以下代码在 IE 中有效并提示27,但在 Firefox 中则提示0$('body').keypress(function(e){alert(e.which);if(e.which == 27){// Close my modal window}});
2010-07-30
我有两个函数。按下 Enter 键时,函数运行正常,但按下 Esc 键时则不运行。Esc 键的正确数字是多少?$(document).keypress(function(e) {if (e.which == 13) $('.save').click(); // enter (works as expected)if (e.which == 27) $('.cancel').click(); /
2009-07-21
我正在使用 reactjs,在尝试显示 JSON 数据(来自文件或服务器)时似乎无法防止此错误:Uncaught TypeError: this.props.data.map is not a function我查看过:React 代码抛出“TypeError:this.props.data.map 不是函数”React.js this.props.data.map() 不是函数这些都没有帮助我解
2015-05-09
我的代码有什么问题?Uncaught TypeError: Cannot read properties of undefined (reading 'remove')和Uncaught TypeError: Cannot read properties of undefined (reading 'add')document.querySelector("#elastic").oninput =
2022-01-15
我正在尝试使用以下技术来格式化用户输入值,但是在 Fire Bug 控制台上出现以下错误$(this).val().toFixed 不是函数$(".amount-text").bind('change',function () {$(this).val(($(this).val()).toFixed(2));});有人可以帮我吗?
2010-09-16
Number(123.456).toFixed(20)发出"123.45600000000000306954"306954来自哪里?我知道以二进制表示的数字不可能准确。但我在文档中没有找到任何提及调用 number(/.../) 会导致精度损失的信息。mdn说A string representation of number that does not use exponentialnotatio
2012-05-15
我正在参加在线编码课程,但一直收到此错误:Line 18, TypeError: Cannot call method 'toFixed' of undefined不确定哪里出了问题。以下是完整代码://Calculate the area of a rectanglefunction calculateArea(length, width) {return length * width;}fun
2013-04-21
我正在尝试学习 Javascript 并创建一些简单的脚本,我试图为我自己创建一个运输成本脚本。计算到达物品的运输成本。除了数字格式之外,一切都正常。我尝试使用toFixed()方法格式化数字。但它不起作用。我检查了控制台,结果是Uncaught TypeError: undefined is not a function (index):23calculate (index):23onclick
2014-06-16
我一直在查看代码并将其分解,但似乎找不到导致错误的原因。我不确定我对 .toFixed 做错了什么,导致代码中断。你能帮忙吗?代码(已更正)<script type="text/javascript">$(document).ready(function(){function getTotal() {var quantity = $('#tmp_quantity').val();var name
2015-08-10
嗨,问题如下:我定义:var total = 0;function add(a){total+=a;var float_num = total.toFixed(2);return float_num;}JS 给我一个错误说 Uncaught TypeError total.toFixed 不是函数我不明白。我声明的总数不是数字类型?
2015-08-11
尝试在计算器上显示数字,但它说这不是一个函数。我以前使用过 Number(variable.toFixed(x)),但这次它似乎在 document.getlementbyid 中不起作用。有什么帮助吗? if (vi === 0){document.getElementById('result').innerHTML =Number(reactant.toFixed(13));} else
2018-06-18
为什么当我想将格式化的数字分配给变量时会显示错误?var jsObject = new Object();jsObject.number = 0;for (i = 1; i <= 10; i++) {jsObject.number += 0.1;console.log((jsObject.number).toFixed(1)); // works and shows right numbersjs
2018-09-10
我试图了解为什么我的代码块不起作用。我正在使用 JQuery 以及 vanilla JS。这是我的代码。// update every 1 second on time.setInterval(function() {// get current time and duration of entire videolet getTimePaused = video.currentTime;let v
2019-03-27