我已经使用 Ag-Grid 的企业功能“ agSetColumnFilter ”几个月了,没有出现任何问题。
我正在使用以下版本:
"ag-grid": "^17.1.1",
"ag-grid-enterprise": "^17.1.1",
"ag-grid-react": "^17.1.0",
Run Code Online (Sandbox Code Playgroud)
经过一些重构后,只需单击过滤器菜单后,我就开始收到此错误:
ag-grid: Looking for component [agSetColumnFilter] but it wasn't found.
Array.concat.ComponentProvider.retrieve @ componentProvider.js?6ebb:209
Array.concat.ComponentResolver.resolveByName @ componentResolver.js?1587:159
Array.concat.ComponentResolver.getComponentToUse @ componentResolver.js?1587:155
Array.concat.ComponentResolver.newAgGridComponent @ componentResolver.js?1587:271
Array.concat.ComponentResolver.createAgGridComponent @ componentResolver.js?1587:236
Array.concat.FilterManager.createFilterInstance @ filterManager.js?d1c0:376
Array.concat.FilterManager.createFilterWrapper @ filterManager.js?d1c0:393
Array.concat.FilterManager.getOrCreateFilterWrapper @ filterManager.js?d1c0:343
Array.concat.StandardMenuFactory.showPopup @ standardMenu.js?505d:52
Array.concat.StandardMenuFactory.showMenuAfterButtonClick @ standardMenu.js?505d:45
Array.concat.HeaderComp.showMenu @ headerComp.js?f669:122
(anonymous) @ headerComp.js?f669:107
componentResolver.js?1587:274 Error creating component filter=>agTextColumnFilter
Array.concat.ComponentResolver.newAgGridComponent @ componentResolver.js?1587:274
Array.concat.ComponentResolver.createAgGridComponent @ componentResolver.js?1587:236
Array.concat.FilterManager.createFilterInstance @ filterManager.js?d1c0:376
Array.concat.FilterManager.createFilterWrapper @ filterManager.js?d1c0:393
Array.concat.FilterManager.getOrCreateFilterWrapper @ filterManager.js?d1c0:343
Array.concat.StandardMenuFactory.showPopup @ …Run Code Online (Sandbox Code Playgroud) 我最近阅读了 Node 的“worker_threads”模块,该模块允许在多个线程中并行执行 Javascript 代码,这对于 CPU 密集型操作非常有用。(注意:这些不是 Chrome 在浏览器中制作的网络工作者)
我正在构建一个功能,我需要在不阻止浏览器的情况下执行大量 Postgres INSERT。
问题是:在我实例化 worker 的 Javascript 文件中,我不允许导入任何内容,包括本机 Node 模块或 NPM 库,如执行数据库查询所必需的 Knex.js。我收到一条错误消息:文件一执行,就不能在模块外使用 import 语句。
我试过将工作代码放在另一个文件中,顶部有一个导入语句(同样的错误)。我尝试将 Knex 对象提供给 workerData,但它无法克隆非本地 JS 对象。
我没有想法 - 如果我们不能导入任何 NPM 库,有没有人知道如何在工作线程中与数据库交互?!?!
// mainThread.js
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
import knex from 'knex'; // --> *** UNCAUGHT EXCEPTION: Cannot use import statement outside a module ***
if (isMainThread) {
module.exports = async function runWorker (rowsToInsert = []) {
return new …Run Code Online (Sandbox Code Playgroud) worker-thread node.js import-module node-cluster node-worker-threads