gpt4 book ai didi

javascript - taggingJS 在输入时抛出错误。又名句号

转载 作者:行者123 更新时间:2023-12-02 21:35:04 25 4
gpt4 key购买 nike

我将其用于标签:https://github.com/sniperwolf/taggingJS/

下面的代码用于初始化taaggingJS

var myOptions =
{
"no-duplicate": true,
"no-duplicate-callback": null,
"type-zone-class": "type-zone",
"tag-box-class": "tagging",
"forbidden-chars": ["!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "=", "+", "`", "~", "[", "]", "{", "}", "|", ";", ":", "'", "<", ">", ",", ".", "/", "?"],
"forbidden-chars-callback": null
// chars not included ",
};

$("#post_tags").tagging(myOptions);

每当我输入时。 (句号) 在 div 中,它响应一个错误,指出

Uncaught TypeError: b is not a function at n.throwError (tagging.min.js:1)

不明白为什么?有人可以帮忙解决这个问题吗?

最佳答案

forbidden-chars-callback 是配置参数,它决定发现禁止字符时要执行的操作。该参数的默认值为“window.alert”,这就是为什么在输入禁止字符时出现警报的原因。

forbidden-chars-callback 需要一个函数,其中您已将“null”传递给它,这就是抛出错误的原因。

现在,根据您的要求,不需要显示警报并且不显示此类错误。您可以传递一个匿名函数,它不会执行任何操作来避免 JavaScript 错误。

看看JS代码

var myOptions = {
"no-duplicate": true,
"no-duplicate-callback": null,
"type-zone-class": "type-zone",
"tag-box-class": "tagging",
"forbidden-chars": ["!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "=", "+", "`", "~", "[", "]", "{", "}", "|", ";", ":", "'", "<", ">", ",", ".", "/", "?"],
"forbidden-chars-callback": function(){}
};

$("#post_tags").tagging(myOptions);

可用规范的完整列表:
https://github.com/sniperwolf/taggingJS/#available-options

要查看完整的 JS 文件,请访问 url:
https://cdn.rawgit.com/sniperwolf/taggingJS/master/tagging.js

enter image description here

关于javascript - taggingJS 在输入时抛出错误。又名句号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60520379/

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