我正在尝试在我的项目中使用Tagify,但要么文档不清楚如何使用它,要么我在JS方面是最糟糕的人。我将import Tagify from '@yaireo/tagify';添加到我的app.js中,并对其进行了编译,没有错误,但随后我返回到app.js,我得到了'Tagify' is declared but its value is never read的集成开发环境警告,我不知道该如何处理这个问题。控制台中也出现i get the Uncaught ReferenceError: Tagify is not defined错误。
另外,我在刀片文件中使用以下脚本在文本框上使用tagify:
<script>
var input = document.querySelector('textarea[name=webskills]'),
tagify = new Tagify(input, {
enforceWhitelist : true,
delimiters : null,
whitelist : ["The Shawshank Redemption", "The Godfather", "The Godfather: Part II", "The Dark Knight", "12 Angry Men", "Schindler's List", "Pulp Fiction",],
callbacks : {
add : console.log, // callback when adding a tag
remove : console.log // callback when removing a tag
}
});
</script>发布于 2020-12-24 02:57:16
如果不使用tagify变量,则不需要tagify = new Tagify(...,只需编写:
<script>
var input = document.querySelector('textarea[name=webskills]')
new Tagify(input, {
enforceWhitelist : true,
delimiters : null,
whitelist : ["The Shawshank Redemption", "The Godfather", "The Godfather: Part II", "The Dark Knight", "12 Angry Men", "Schindler's List", "Pulp Fiction",],
callbacks : {
add : console.log, // callback when adding a tag
remove : console.log // callback when removing a tag
}
})
</script>您看到的这条警告可以安全地忽略,因为它是无关紧要的。
https://stackoverflow.com/questions/64760141
复制相似问题