Я только что установил через yarn install
typeahead.js libreary.
Это мой app.js, вам не нужно читать весь код. Это не имеет значения:
import $ from 'jquery';
import 'typeahead';
const Bloodhound = require('imports-loader?define=>false!typeahead.js/dist/bloodhound.min.js');
$(document).ready(function () {
var bestPictures = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: 'http://twitter.github.io/typeahead.js/data/films/post_1960.json',
remote: {
url: 'http://twitter.github.io/typeahead.js/data/films/queries/%QUERY.json',
wildcard: '%QUERY'
}
});
$('#custom-templates .typeahead').typeahead(null, {
name: 'best-pictures',
display: 'value',
source: ['a'],
templates: {
empty: [
'<div class="empty-message">',
'unable to find any Best Picture winners that match the current query',
'</div>'
].join('\n'),
suggestion: function() {
return '<div><strong>a</div>';
}
}
});
это часть моего конфига веб-пакета:
Encore
.setOutputPath('web/' + buildFolder + '/')
.setPublicPath('/' + buildFolder)
.addEntry('app', './assets/js/app.js')
.autoProvidejQuery()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
.enableSassLoader()
.enablePostCssLoader()
.addPlugin(new CopyWebpackPlugin([
{from: 'assets/img', to: './img'},
])).autoProvideVariables({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
В целом я получаю эту огромную ошибку:
TypeError:
jquery__WEBPACK_IMPORTED_MODULE_0 ___ default (...) (...). typeahead не
функция
Уже пробовали это решение , но та же проблема.
Любая помощь будет оценена.