【发布时间】:2020-12-24 02:57:15
【问题描述】:
我正在尝试在我的项目中使用 Tagify,但要么文档不清楚如何使用它,要么我是 JS 最糟糕的人。我在我的app.js 中添加了import Tagify from '@yaireo/tagify'; 并编译它没有错误,但后来我返回到app.js 我收到了'Tagify' is declared but its value is never read 的IDE 警告,我不知道该怎么做。也在控制台 i get the Uncaught ReferenceError: Tagify is not defined报错。
另外,我在刀片文件中使用以下脚本在文本框上使用标记:
<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>
【问题讨论】:
-
我认为您缺少一些关于如何捆绑 app.js 以及是否/如何将其包含在页面中的细节。
-
我像这样捆绑我的 app.js,除了标记其他一切都在工作。我也将它包含在我的页面中,例如
<script src="{{ asset('js/app.js') }}"></script>,除了这个之外,一切都在正常工作。我想你是对的。不知道如何在我的包中包含 tagify。window.$ = window.jQuery = require('jquery'); window.Popper = require('popper.js').default; require ('./bootstrap'); var Turbolinks = require("turbolinks"); Turbolinks.start(); import Tagify from '@yaireo/tagify';
标签: javascript tagify