gpt4 book ai didi

tabulator 没有找到匹配选择器的元素

转载 作者:行者123 更新时间:2023-12-01 21:58:19 25 4
gpt4 key购买 nike

尝试第一个 super 基本制表符并遇到控制台错误“找不到匹配选择器的元素”。我尝试了几个不同的例子,无法弄清楚我做错了什么。命名应该是这样的吗?

<html>
<head><title>Test for tabulator</title>
<link href="dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="dist/js/tabulator.min.js"></script>
<script>
//define data
var tabledata = [
{id:1, name:"Oli Bob", location:"United Kingdom", gender:"male", rating:1, col:"red", dob:"14/04/1984"},
{id:2, name:"Mary May", location:"Germany", gender:"female", rating:2, col:"blue", dob:"14/05/1982"},
{id:3, name:"Christine Lobowski", location:"France", gender:"female", rating:0, col:"green", dob:"22/05/1982"},
{id:4, name:"Brendon Philips", location:"USA", gender:"male", rating:1, col:"orange", dob:"01/08/1980"},
{id:5, name:"Margret Marmajuke", location:"Canada", gender:"female", rating:5, col:"yellow", dob:"31/01/1999"},
{id:6, name:"Frank Harbours", location:"Russia", gender:"male", rating:4, col:"red", dob:"12/05/1966"},
{id:7, name:"Jamie Newhart", location:"India", gender:"male", rating:3, col:"green", dob:"14/05/1985"},
{id:8, name:"Gemma Jane", location:"China", gender:"female", rating:0, col:"red", dob:"22/05/1982"},
{id:9, name:"Emily Sykes", location:"South Korea", gender:"female", rating:1, col:"maroon", dob:"11/11/1970"},
{id:10, name:"James Newman", location:"Japan", gender:"male", rating:5, col:"red", dob:"22/03/1998"},
];

//define table
var table = new Tabulator("#example-table", {
data:tabledata,
autoColumns:true,
});
</script>
</head>
<body>
<h1>test tabulator </h1>
<div id="example-table"></div>
</body>
</html>

有什么明显的我想念的吗?这是从示例中复制/粘贴的。

最佳答案

是的,因为当您访问它时该元素不存在。在 div 之后移动你的 javascript,它应该可以工作。或者使用页面加载事件:

底页:

<div id="example-table"></div>
<script>
var table = new Tabulator("#example-table", {
data:tabledata,
autoColumns:true,
});
</script>

页面加载:

window.addEventListener("load", function() {
var table = new Tabulator("#example-table", {
data:tabledata,
autoColumns:true,
});
},false);

关于tabulator 没有找到匹配选择器的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55052701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com