草庐IT

after_filter

全部标签

javascript - 对象不支持属性或方法 'filter'

我遇到了一个IE8问题,我最初认为这是由于IE8缺乏对indexOf()属性的支持,但事实似乎并非如此。我通过原型(prototype)实现了indexOf()但仍然不断收到错误消息-对象不支持属性或方法'filter'我的代码在passedArray.filter行出错。functionconsolidatedFilters(passedArray,passedFilter,passedFilterType)if(passedFilterType=="specialty"){varfilteredArray=passedArray.filter(function(el){for(ii

javascript - knockout : How to filter observableArray by param

这是代码:http://jsfiddle.net/Gr3fT/1/如何通过role属性过滤personRoles?每个列表必须只有自己的role项。谢谢。 最佳答案 此功能有效(基于http://knockoutjs.com/examples/animatedTransitions.html:)get:function(role){returnko.dependentObservable(function(){returnko.utils.arrayFilter(this.personRoles(),function(item){r

javascript - 引用错误 : You are trying to `import` a file after the Jest environment has been torn down

我有一个组件使用来自ReactNative的Animated组件。我开始编写一个测试用例来模拟组件的onPress,它调用一个函数,其中包含Animated.timing和setState。运行jest工作正常,但测试永远不会停止运行,而且我之前编写的一个不相关的测试用例现在似乎从未通过(之前通过)。运行jest--watch,我得到这个错误:ReferenceError:Youaretryingto`import`afileaftertheJestenvironmenthasbeentorndown.atFunction.bezier(node_modules/react-nativ

javascript - 缺少 : after property ID

我不明白我在这里做错了什么...第3行报告丢失:在属性ID之后$(document).ready(function(){$('#imagegalleryimg').each(function({$(this).css({width:'100%'});});$('#imagegallery').cycle({timeout:0,fx:'scrollHorz',width:'100%',height:'auto',next:'.next',prev:'.prev'});$("#imagegallery").touchwipe({wipeLeft:function(){$("#imagega

javascript - Webkit 错误 : Overflow auto triggered after resizing a child element to matching size

我有以下简单设置:document.getElementById('inner').addEventListener('click',({target})=>{target.classList.add('match');});#container{background:green;overflow:auto;width:200px;height:100px;}#inner{width:210px;height:110px;}#inner.match{width:200px;height:100px;}单击内部元素后,我希望父元素上的滚动条消失,因为这两个元素现在具有匹配的大小。这在Fi

Javascript DataTables - filter() 函数未按预期工作

我正在使用DataTablesjavscript库,我正在尝试根据数值是否大于60来过滤掉一行。我正在尝试遵循这个例子:http://datatables.net/reference/api/filter%28%29过滤器代码如下所示:table.column(3).data().filter(function(value,index){returnvalue>60?true:false;})问题是所有行仍然可见,根本没有进行过滤。即使我的函数只返回false,所有行仍然可见。这是怎么回事?JSFiddle示例http://jsfiddle.net/1hLcpr3x/

javascript - 这个错误 "Declaration of instance field not allowed after declaration of instance method."是什么意思

在我的Angular2项目中,我收到此错误:“在声明实例方法之后不允许声明实例字段。相反,这应该出现在类/接口(interface)的开头。(成员排序)”我想了解如何解决这个问题以及我为什么会遇到这个问题。错误与下一段代码中的私有(private)函数有关:exportclassHomeComponentimplementsOnInit{publicerror:string;publicshirts=[];constructor(publicrest:RestService,publicscService:ShoppingCartService,publicsnackBar:MdSna

javascript - Angular 错误 : [filter:notarray] Expected array but received: {} with a filter on an ng-repeat

我正在尝试使用ng-repeat指令使用对API的Angular请求来填充html表。首先加载html页面,然后请求获取返回响应时填充表格的数据。当我向ng-repeat指令添加过滤器时,表格被填充并且过滤器起作用,但是在我的chrome浏览器控制台中,我收到以下错误:Error:[filter:notarray]Expectedarraybutreceived:{}http://errors.angularjs.org/1.4.3/filter/notarray?p0=%7B%7DatREGEX_STRING_REGEXP(angular.js:68)atangular.js:182

javascript - 在 jQuery 中使用 filter() 更有效,还是只在 each() 中使用?

我目前有代码通过jQuery提取数据,然后使用each方法显示它。但是,我遇到了排序问题,所以我研究了在sort之前使用并添加了jQuery的filter方法(这是有道理的)。我现在正在考虑删除sort,我想知道我是否应该按原样保留filter调用,还是将其移回每个。jQueryAPIdocumentationforfilter中的示例坚持样式结果,而不是文本内容的输出(具体来说,不使用each())。文档目前指出“[t]他提供的选择器针对每个元素进行了测试[...]”,这让我相信做一个filterandeach会导致未过滤的元素被循环两次,而如果仅在each循环中进行检查则只会循环一

javascript - JQuery grep(...) VS 原生 JavaScript filter(...) 函数性能

我测量了这两个函数的执行时间:jQuerygrep功能原生JavaScriptfilter功能已使用Chrome配置文件工具测量了以下方法的执行情况://jQueryGREPfunctionfunctionalternative1(words,wordToTest){return$.grep(words,function(word){returnwordToTest.indexOf(word)!=-1;});}//NativejavascriptFILTERfunctionfunctionalternative2(words,wordToTest){returnwords.filter