草庐IT

Function_Reference

全部标签

javascript - Push is not a function JavaScript 错误

在下面的代码中,出现“推送不是函数”错误。任何人都可以让我知道我在这里做错了什么吗?我正在尝试用Javascript创建二维数组。varmyArray=newArray(4);myArray=["0","0","0","0"];for(vari=0;iFirebug指向我:myArray[i].push("ID");对于这一行,我收到“TypeError:myArray[i].pushisnotafunction”最终的数组应该是这样的:[ID,"SomeValue1"],[ID,"SomeValue2"],[ID,"SomeValue3"]而且我不能硬编码,我需要根据数据库中的数据动

javascript - 如何获取 firebase.database.Reference 完整路径

考虑varadaRef=firebase.database().ref("users/ada");如何获取ref的完整路径?那是“用户/ada”? 最佳答案 这非常简单:adaRef.toString()将打印完整的URL:https://firebaseio.com/users/ada因此,为了获取路径,您可以将其子串化。有两种方法:adaRef.toString().substring(firebase.database().ref().toString().length-1)或:adaRef.toString().substr

javascript - Node : Wrapping entire script in a function call

我一直在用nodejs编写如下模块:module.exports=function(logger,db,external,constants){return{//something}}最近我团队中有人建议将整个脚本包装在一个函数中以避免变量的全局混淆,即像这样:(function(){'usestrict';module.exports=function(logger,db,external,constants){return{//something}}}());据我所知,这种做法通常用于客户端代码。但是在nodejs的服务器端,这是必需的吗?我认为在nodejs中确实没有全局作用域,

javascript - "Unable to get property ' getData ' of undefined or null reference"在 IE 但不是 Chrome

感谢另一位成员的帮助,我成功地实现了一个JS方法,该方法能够粘贴excel数据并将其拆分为HTML文本框表格形式(seethread)。我现在面临的问题是这只在Chrome中有效,而IE10和IE11都标记了以下错误:“无法获取未定义或空引用的属性‘getData’。”此错误在函数的第2行(如下)中抛出:function(event){varinput_id=$(this).attr("id");varvalue=event.originalEvent.clipboardData.getData('text/plain');//ERRORinIE/*...*/event.prevent

javascript - 未捕获的 InvalidValueError : initMap is not a function

我正在尝试加载带有一些特定参数的谷歌地图。我知道问题很可能是需要全局声明initMap函数。然而,我不知道如何,即使在搜索了许多具有类似问题的StackOverflow帖子之后也是如此。其他vardatabaseArray=[{id:'BTS1',arfcn:'70',bsic:'29'},{id:'BTS2',arfcn:'60',bsic:'28'},{id:'BTS3',arfcn:'65',bsic:'27'},{id:'BTS4',arfcn:'55',bsic:'26'},{id:'BTS5',arfcn:'75',bsic:'29'}];varlocationArray=

javascript - 未处理的 promise 拒绝警告 : This error originated either by throwing inside of an async function without a catch block

我的Node-Express应用出现以下错误UnhandledPromiseRejectionWarning:Unhandledpromiserejection.Thiserrororiginatedeitherbythrowinginsideofanasyncfunctionwithoutacatchblock,orbyrejectingapromisewhichwasnothandledwith.catch().(rejectionid:4)至少可以说,我创建了一个看起来像这样的辅助函数constgetEmails=(userID,targettedEndpoint,headerA

JavaScript 符号 : (function() { . .. } )();

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicate:WhatisthepurposeofwrappingwholeJavascriptfilesinanonymousfunctionslike“(function(){…})()”?大家好,我见过几个使用这种表示法的JavaScript文件:JavaScript文件的开始:(function(){//Allfunctionsgohere.//Cansomeonesaywhatthewrappingnamelessfunctionisusedfor?})();还有原型(prototype)库,这似乎是可能的:fu

javascript - NodeJs 使用 ExpressJs : TypeError: string is not a function at Function. app.render

我刚开始学习Node,我正在尝试使用Node和Express构建Web应用程序。我的app.js文件中有以下代码,具有以下目录结构。目录结构:appassetscontrollermodelviewindex.jadeglobalnode_modulesapp.jspackage.json-js-varexpress=require('express');varapp=express();app.configure(function(){app.set('view',__dirname+'/app/view');app.set('viewengine','jade');app.use(

javascript - 类型错误 : getState is not a function when adding middleware to Redux

在我的configureStore.dev.js文件中使用此代码,在添加applyMiddleware(reduxImmutableStateInvariant)时,我得到一个UncaughtTypeError:getStateisnotafunction。当我删除这个添加的中间件时,我的项目运行正常。添加此中间件的正确方法是什么?这是完整的文件:import{createStore,compose,applyMiddleware}from'redux';importrootReducerfrom'../reducers';importreduxImmutableStateInvari

javascript - Angular JS 类型错误 : $http is not a function

我已经阅读了所有人们遇到$http不是函数的问题的帖子,看起来大部分是由于注入(inject)顺序错误所致。我的模块定义如下:angular.module("app",[]).controller("appCtrl",['$scope','$http',function($scope,$http){...$scope.makeCall=function($http){console.log("HERE");$http({method:'GET',url:如有任何建议,我们将不胜感激。 最佳答案 从makeCall函数中删除$http