簡體   English   中英

JQuery為什么我的array.every不是函數?

[英]JQuery Why my array.every is not a function?

我想知道為什么我的array.every不是一個函數,我搜索幾個小時,但我不明白為什么它不是。 有人能幫我嗎 ?

 function controlUserInput(inputText, appLang) { const regex = /\\$[^$]*\\$/gm; const str = $('#formulaire-preview-textarea').val(); let m; var array = populateVariable(appLang); while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); var isEqual = match.length==array.length; for (i=0; i<=array.length-1;i++){ if(displayCpt == 4 && isEqual && match.toArray().every(function(paramInMatch){ return $.inArray(paramInMatch, array) != -1; })){ osapi.jive.core.container.sendNotification({ "message": "Toutes les valeurs rentrées sont correctes", "severity": "success" }); }else{ osapi.jive.core.container.sendNotification({ "message": "Vous n'avez pas utilisé toutes les valeurs", "severity": "error" }); } } }) }; } 

.toArray()是一個jQuery對象方法,因為你的match不是jQuery對象,所以它不起作用。

你可以使用普通的javascript Array.from(match)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM