Materialize不显示自动完成选项,它是从官方实现站点复制的代码,但无法像在网站上那样工作。 在控制台中,我收到此错误:
Uncaught TypeError: r.autocomplete is not a function
at r.fn.init.chips (materialize.min.js:6)
at HTMLDivElement.<anonymous> (materialize.min.js:6)
at Function.each (jquery-3.2.1.min.js:2)
at r.fn.init.each (jquery-3.2.1.min.js:2)
at r.fn.init.init (materialize.min.js:6)
at r.fn.init.t.fn.material_chip (materialize.min.js:6)
at (index):396
部分代码:
<div class="chips chips-autocomplete"></div>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
$('.chips-autocomplete').material_chip({
autocompleteOptions: {
data: {
'Apple': null,
'Microsoft': null,
'Google': null
},
limit: Infinity,
minLength: 1
},
data: [
{% for tag in post.tags.all %}
{tag: '{{tag.tag}}',},
{% endfor%}
],
placeholder: 'Adaugă o etichetă',
secondaryPlaceholder: '+Etichetă',
});