草庐IT

Find_all

全部标签

javascript - 巴别塔错误 : "Couldn' t find preset 'latest' relative to directory"when preset was installed globally

这个问题在这里已经有了答案:Error:Couldn'tfindpreset"react"wheninstalledusingnpminstall--globalbabel-preset-reactbutworkswithoutglobalflag(2个答案)关闭6年前。我是这样全局安装Babel的:npminstall-gbabel-clinpminstall-gbabel-preset-latest我知道不建议在全局范围内这样做,但我更喜欢这种方式来保持我的目录干净(没有node_modules/也没有package.json)然后我有一个用ES6编写的mainES6.js文件,我

javascript - Array.find(value) 返回值 'is not a function'

我正在尝试在AngularJS数组上使用JavaScript的find()函数。这是合法的,对吧...?这个非常简单的代码给我带来了一些问题。这是说$scope.names.find(name1)的返回值不是函数。TypeError:Name1不是函数if($scope.names.find(name1)!==name1){$scope.names.push(name1);}我也试过...if($scope.names.find(name1)===undefined){$scope.names.push(name1);}和if(!$scope.names.find(name1)){$s

javascript - typescript 编译器错误 TS2307 : Cannot find module 'jquery'

我正在关注JSPM入门guide我想安装jquery包,所以我执行下面的命令。jspm安装jquery但是当我尝试像下面这样用typescript导入它时从“jquery”导入$我从typescript编译器中收到一个错误,提示errorTS2307:Cannotfindmodule'jquery'。不仅对于这个库,对于其他库我也遇到同样的错误。 最佳答案 您需要在编译上下文中包含jquery的类型定义,您可以从https://github.com/DefinitelyTyped/DefinitelyTyped中获取它们

javascript - 全日历.io : how to display one event per line in agendaWeek then mix all in one?

我使用Fullcalendar.iov2在我的agendaWeek模组中,我有事件,所有事件都显示在日广场的一行中。所以,我有更多的事件,然后是更薄的事件block。如何每行显示一个事件?就像在monthmod中一样。我有更多的事件,然后更高的日block将我(高度)。也许,很难使用像eventRender这样的函数,因为如果你检查.fs-event元素(web开发者工具),你会看到事件block使用了position:absolute;top:300px;left:33%...所以我不知道该怎么做。我想要这样的东西: 最佳答案 我

javascript - 实现 Promise.all

这个问题在这里已经有了答案:JavaScriptclosureinsideloops–simplepracticalexample(44个答案)关闭6年前。exercises之一在EloquentJavascript这本书的第17章是实现Promise.all()方法,我想出了这个实现(不起作用):functionall(promises){returnnewPromise(function(success,fail){varsuccessArr=newArray(promises.length);if(promises.length==0)success(successArr);va

javascript - 为什么定义了 document.all 但 typeof document.all 返回 "undefined"?

这个问题在这里已经有了答案:Whyisdocument.allfalsy?(4个答案)关闭6年前。我在研究JavaScript的typeof运算符时,偶然发现了以下怪异之处:ExceptionsAllcurrentbrowsersexposeanon-standardhostobjectdocument.allwithtypeUndefined.typeofdocument.all==='undefined';Althoughthespecificationallowscustomtypetagsfornon-standardexoticobjects,itrequiresthoset

javascript - 为什么直接将 Promise.all 传递给 .then 函数会抛出错误?

我想直接将Promise.all传递给.then函数,例如:consttest=[Promise.resolve(),Promise.resolve(),Promise.resolve(),Promise.resolve()];Promise.resolve(test)//It'ssupposedtobeanAJAXcall.then(Promise.all)//Getanarrayofpromises.then(console.log('End');但是这段代码抛出错误Uncaught(inpromise)TypeError:Promise.allcalledonnon-object

javascript - yield [] 和 yield all() 的区别 - ES6/redux-saga

与ES6的内置yield[]相比,使用redux-saga的yieldall([])有什么优势吗?要并行运行多个操作,redux-saga建议:constresult=yieldall([call(fetchData),put(FETCH_DATA_STARTED),]);但是不用​​all()方法也可以完成同样的事情:constresult=yield[call(fetchData),put(FETCH_DATA_STARTED),];哪个更好,为什么? 最佳答案 没有功能差异,正如MateuszBurzyński(redux-s

javascript - Jest : cannot find module required inside module to be tested (relative path)

我有这个组件:importReactfrom'react';importVideoTagfrom'./VideoTag';importJWPlayerfrom'./JWPlayer';classVideoWrapperextendsReact.Component{//...componentcode}基于某些逻辑在内部呈现另一个组件(VideoTag或JWPlayer)但是当我尝试在一个Jest文件中测试它时我得到错误:找不到模块'./VideoTag'这三个组件在同一个目录中,这就是为什么当我转译它并在浏览器中看到它在运行时它实际上有效但看起来Jest在解析这些相对路径时遇到问题,这

javascript - 带有 .find() 的正则表达式,没有结果

我正在尝试更改页面上的id和name属性。我使用的代码是这样的:varimg=newRegExp('id*="launch_pad_image_slide_\d"',g);$('.slider-data').each(function(){$(this).find(img).attr('id','randomstuff');});假设.find函数应该获取里面的整个id:id="launch_pad_image_slide_2"...但它不起作用。5个小时就这样,累坏了。建议?基本上每次删除一个字段时,jQuery都必须遍历它们并正确编号它们的id/name属性以避免重复。