gpt4 book ai didi

javascript - Gridster 未出现在 jQuery 变量下

转载 作者:行者123 更新时间:2023-11-29 21:55:29 25 4
gpt4 key购买 nike

我正在使用 Gridster 在我的应用程序中呈现图 block 布局,使用 NodeBB 作为基础。

代码如下:

<script src="/jquery.js"></script>
<script src="/gridster.js"></script>

<script>
$.noConflict();
jQuery(function () {
jQuery(".gridster ul").gridster({
widget_margins: [10, 10],
widget_base_dimensions: [175, 175],

serialize_params: function(wi, wgd) {
console.log($(wi).attr('id'));
return {
id: $(wi).attr('id'),
col: wgd.col,
row: wgd.row,
size_x: wgd.size_x,
size_y: wgd.size_y
};
},

draggable: {
start: function () {
dragged = 1;
},
stop: function () {
setTimeout(function () {
dragged = 0;
}, 5);
}
}
});
});
</script>

如您所见,我已尝试在 <script> 中初始化 Gridster标签,但是当我运行它时,我得到:

Uncaught TypeError: undefined is not a function

尝试访问 gridster ( $('.gridster ul').gridster( \\ .. ) 时。 jQuery 很好,它只是 Gridster。

为什么?

最佳答案

看起来您可能使用了源文件,而不是 gridster 的编译版本。你是从 GitHub 下载的吗?使用 dist/jquery.gridster.min.js,而不是 src/jquery.gridster.js

为了将来引用,src/ 中的版本供 Grunt 编译时使用。 .

关于javascript - Gridster 未出现在 jQuery 变量下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26615158/

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