我正在使用Grid.js库来构建WordPress网站中的表格。搜索了很多文档,但找不到 * 如何添加链接 * 到名称的第一列中,以在新的选项卡中打开,该选项卡是数组对象。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
href="https://unpkg.com/gridjs/dist/theme/mermaid.min.css"
rel="stylesheet"
/>
<title>Grid.js Hello World</title>
</head>
<body>
<h1>
Grid.js Hello World
</h1>
<div id="wrapper"></div>
<script src="https://unpkg.com/gridjs/dist/gridjs.umd.js"></script>
<script src="src/index.js"></script>
</body>
</html>
JS文件:
new gridjs.Grid({
columns: ["Name", "Email", "Phone Number"],
search: true,
data: [
["John", "[email protected]", "(353) 01 222 3333"],
["Mark", "[email protected]", "(01) 22 888 4444"],
["Eoin", "[email protected]", "0097 22 654 00033"],
["Sarah", "[email protected]", "+322 876 1233"],
["Afshin", "[email protected]", "(353) 22 87 8356"]
]
}).render(document.getElementById("wrapper"));
输出
2条答案
按热度按时间gajydyqb1#
您可以使用
formatter
选项和gridjs.html()
函数添加自定义HTML。举例来说:工作代码沙箱:https://codesandbox.io/s/gridjs-hello-world-forked-u52kyg?file=/src/index.js
来源:https://gridjs.io/docs/examples/html-cells
gopyfrb32#
您可以使用gridjs提供的自定义单元格格式化程序。
参考编号:https://gridjs.io/docs/examples/html-cells/
我的工作代码沙盒链接:https://codesandbox.io/s/gridjs-hello-world-forked-uvsgom