【发布时间】:2021-09-07 02:03:16
【问题描述】:
我是 React 新手,我希望在没有 Node.js 的 Django 应用程序中使用 react-table。我已经在我的应用程序中嵌入了带有标准 unpkg 链接的 react-table 库,但是当我在 .js 文件中使用它的函数时,我得到了像 app.js:39 Uncaught ReferenceError: useTable is not defined 这样的错误。所有教程都导入useTable 到import { useTable } from 'react-table',但是当您只是尝试在浏览器中实现这个客户端时,这是不可能的。如果没有 Node.js 及其 import 函数,我将如何使用 react-table?
【问题讨论】:
-
这个例子使用 React 和 react-table。 codesandbox.io/s/github/tannerlinsley/react-table/tree/master/…
-
@SanishJoseph 是的,但该示例使用 Node.js 和
import函数。我正在尝试在没有 Node.js 的情况下使用 React Table,但我不知道如何在没有 Node 的情况下访问它的任何方法。 -
你说的是哪些功能?如果是
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow, } = useTable({ columns, data, })他们不是来自 Nodejs。 -
你是想说你想使用 react-table 而不用 react 吗?
-
不,我在我的 HTML 文件中嵌入了 React 和 React-table 作为 unpkg 脚本链接。但是,它无法识别 React-table 中的
useTable函数。我目前认为这是因为我没有使用上面描述的import函数。
标签: javascript reactjs react-table