草庐IT

unused-functions

全部标签

javascript - D3 : use nest function to turn flat data with parent key into a hierarchy

我确信有一种非常简单优雅的方法可以做到这一点,但我不太明白。我有一些看起来像这样的输入数据:[{id:1,name:"Peter"},{id:2,name:"Paul",manager:1},{id:3,name:"Mary",manager:1},{id:4,name:"John",manager:2},{id:5,name:"Jane",manager:2}]如果可能,我想使用d3.js嵌套运算符来获取要在层次结构布局中使用的结构。像这样:[{name:"Peter",children:[{name:"Paul",children:[{name:"John"},{name:"Jan

javascript - Dropzone.js init function() 未被调用

我有这个HTML:RemoveAll和$(document).ready(function(){}中的这个Javascriptwindow.Dropzone;Dropzone.autoDiscover=false;$('#fbDropZone').dropzone={init:function(){fbDropZone=this;$("#removeAllImages").click(function(){fbDropZone.removeAllFiles();})},paramName:"file",maxFilesize:5,maxFiles:1,autoProcessQueue:

javascript - Underscore.js _.isObject = function (obj) { return obj === Object(obj); };

当我们查看Underscore.js源码时,我们可以看到如下内容:_.isObject=function(obj){returnobj===Object(obj);};我知道它有效。但为什么不用这个:_.isObject=function(obj){returntypeofobj==="object";};? 最佳答案 不同之处在于棘手的值null。typeofnull返回'object',这显然很令人困惑,而不是想要的结果。但是,将对象构造函数与null一起使用会导致创建新对象(参见MDN)。这意味着您可以区分对象和null,这是

javascript - gulp karma 测试 TypeError : Server is not a function

尝试使用gulp运行karma以运行测试,但遵循以下示例:https://github.com/karma-runner/gulp-karma我的gulp文件:vargulp=require('gulp');varServer=require('karma').Server;/***Runtestonceandexit*/gulp.task('test',function(done){newServer({configFile:__dirname+'/karma.conf.js',singleRun:true},done).start();});/***Watchforfilechan

javascript - Firebase Cloud Functions https.onCall 已完成,状态代码为 : 204

Firebase函数constfunctions=require('firebase-functions');constadmin=require('firebase-admin');constcors=require('cors')({origin:true});exports.addMessage=functions.https.onCall((data,context)=>{return{text:"Test"};});问题问题是,当我从应用程序调用此函数时,我首先得到完成状态代码:204,然后完成状态代码:200204我怎样才能避免这种情况? 最佳答

javascript - AngularJS fn is not a function error using $timeout with a function with parameters 错误

我正在制作一个您可以编辑文本的网页,在您停止输入1秒后,它会自动保存您输入的内容。目前我正在研究$timeout的细节。当我调用没有参数的update方法时,它可以正常工作,但是当我使用参数调用它时,我得到错误:Error:fnisnotafunction$TimeoutProvider/this.$get为什么我在执行以下操作时会收到此错误:timeout=$timeout(update(element,content),1000);但不是当我这样做的时候:timeout=$timeout(update,1000);显然我需要将参数传递给更新方法,因为我需要知道要更新什么。debou

javascript - 避免 React 中的内联函数 : How to bind functions with arguments?

我正在尝试关注no-bindReact使用他们推荐的ES6类模式的规则:classFooextendsReact.Component{constructor(){super();this._onClick=this._onClick.bind(this);}render(){return(Hello!);}_onClick(){//Dowhateveryoulike,referencing"this"asappropriate}}但是,当我需要将参数传递给_onClick时,需要更改什么?我试过类似的方法:import{someFunc}from'some/path';classFoo

javascript - Cloud Functions for Firebase 超时

用于获取数据库数据的简单云功能无法正常工作。getusermessage()不工作错误:Functionexecutiontook60002ms,finishedwithstatus:'timeout'用于获取数据库结果的Index.JS。constfunctions=require('firebase-functions');constadmin=require('firebase-admin');admin.initializeApp(functions.config().firebase);constcors=require('cors')({origin:true});//Ta

javascript - 弃用警告 : Collection#find: pass a function instead

我是node.js的新手,我目前正在使用discord.js制作Discord机器人。一旦使用了任何bot命令,控制台就会打印出DeprecationWarning。例如:(node:15656)DeprecationWarning:Collection#find:passafunctioninstead(node:15656)有时是另一个数字,几乎总是在变化。这就是我的代码的样子(只有一个命令,我有多个命令,但所有命令都出现此错误):constbotconfig=require("./botconfig.json")constDiscord=require("discord.js")

javascript - JQuery JavaScript 设计 : Self Executing Function or Object Literal?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我很好奇在构造封装代码块时是否有任何与JQuery相关的最佳实践。通常,当我构建一个页面时,我喜欢将该页面中使用的函数封装在一个对象中。这允许我在构建应用程序时进行一些封装。没有什么比看到带有一堆这样的JavaScript文件更让我讨厌的了functiondoSomethingOnlyRelevantOnThisPage(){//dosomestuff}这会导致设计困惑,并且没有很好地封装