草庐IT

a_function_that_may_fail

全部标签

javascript - Meteor:为什么将 function() { } 切换为 () => { } 会丢失我的数据上下文?

所以我正在试验ES6,安装了grigio:babel包,并开始检查我的es5代码并在遇到问题时将其更新为一些新的ES6语法。最初我的模板助手看起来像这样:Template.exampleTemplateName.helpers({exampleHelper:function(){//returnsanarrayfromMongoCollection}});在Blazeeach循环中使用{{#eachexampleHelper}}{{/each}}如您所料,我在这个事件循环中的元素的所有事件处理程序都可以访问exampleHelper通过this关键字。this.exampleField

javascript - 错误 : Task x can't support dependencies that is not an array of strings

我正在关注thistutorial如何开始使用gulp和browserify(以及其他插件)。结构如下:.├──gulpfile.js└──gulp  ├──index.js  └──tasks  ├──browserify.js  └──minifyCss.js/*gulpfile.js*/vargulp=require('./gulp')(['minifyCss','browserify']);gulp.task('default',['minifyCss','browserify']);/*index.js*/vargulp=require('gulp');module.expo

javascript - Foundation 6 - 控制台警告 : Tried to initialize magellan (any JS plugin) on an element that already has a Foundation plugin

我使用bower安装了Foundation6。每次我使用任何Foundation6-JavaScriptbasedplugin时,我都会在控制台中收到多个warning。确切的警告:TriedtoinitializemagellanonanelementthatalreadyhasaFoundationplugin.我的脚本包括如下所示:$(document).foundation();该警告由foundation.js中180行的以下代码触发://Foreachpluginfound,initializeit$elem.each(function(){var$el=$(this),o

Javascript:typeof 说 "function"但它不能作为函数调用

这次我真的对Javascript很困惑:varx=Array.prototype.concat.call;typeofx;//functionx();//UncaughtTypeError:xisnotafunction这到底是怎么回事?如果有帮助,我还注意到:x([1,2],[3,4])也不行toString也认为是一个函数:Object.prototype.toString.call(x);//"[objectFunction]"Array.prototype.concat.apply也会发生这种情况。当它被强制作为一个表达式时它也不起作用:(0,Array.prototype.c

javascript - 未捕获的类型错误 : lang is not a function

这个问题在这里已经有了答案:JSfunctionnamed`animate`doesn'tworkinChrome,butworksinIE(3个答案)关闭6年前。在我的HTML中,我在script标签中定义了lang函数并添加了“TestFire!”单击时必须调用lang的按钮:TestingFunctionsfunctionlang(){alert("Hello,World!It'sJavaScriptthistime");}但是,如果我点击按钮,我会得到这个错误:UncaughtTypeError:langisnotafunction但是,如果我将函数名称从lang更改为任何其他

javascript - 类型错误 : scrollIntoView is not a function

我是react-testing-library/jest的新手,正在尝试编写测试以查看路由导航(使用react-router-dom)是否正确执行。到目前为止,我一直在关注README还有这个tutorial关于如何使用。我的一个组件在本地函数中使用了scrollIntoView,这导致测试失败。TypeError:this.messagesEnd.scrollIntoViewisnotafunction45|46|scrollToBottom=()=>{>47|this.messagesEnd.scrollIntoView({behavior:"smooth"});|^48|}49|

javascript - TypeError [ERR_INVALID_ARG_TYPE] : The "original" argument must be of type Function. 接收类型未定义

在下面的代码中,我得到了这个错误:TypeError[ERR_INVALID_ARG_TYPE]:The"original"argumentmustbeoftypeFunction.Receivedtypeundefinedconstsqlite3=require('sqlite3').verbose();constutil=require('util');asyncfunctiongetDB(){returnnewPromise(function(resolve,reject){letdb=newsqlite3.Database('./project.db',(err)=>{if(e

javascript - 在 nodejs 上访问 function.caller

我有一项任务依赖于function.caller来完整性检查调用者是否获得授权。根据这个url,所有主流浏览器都支持caller...并且我的所有单元测试都通过了:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller但是,nodejs拒绝所有访问function.caller的尝试(将其报告为null)。我愿意接受让这个在nodejs上工作的建议...我不希望这个框架只在浏览器上工作。谢谢! 最佳答案

javascript - Babel/Karma/Chai 给出 TypeError : 'caller' , 'callee' 和 'arguments' properties may not be accessed on strict mode functions

我无法弄清楚为什么这个测试没有通过。varexpect=require('chai').expect;describe('HelloComponent',function(){it('passesaquitesimpletest',function(){expect(1+4).to.equal(5);});});产生这个错误:DEBUG[web-server]:serving:/Users/ivan/dev/react-starter/node_modules/karma/static/context.htmlDEBUG[web-server]:serving(cached):/Use

javascript - Node/ express : Error: Failed to lookup view "error" in views directory

我将我的nodejs模板引擎切换到了ejs(来自jade)。当我使用我的ejs模板运行我的app.js时,我收到一系列“无法在View中查找View‘错误’”日志。其中一些包括:GET/css/bootstrap.min.css50012.588ms-1390Error:Failedtolookupview"error"inviewsdirectory...GET/css/clean-blog.min.cssError:Failedtolookupview"error"inviewsdirectory...GET/js/bootstrap.min.jsError:Failedtoloo