预期行为
使用Javascript(无jQuery)使用自动完成选项创建Chips组件。
当前行为
运行组件我收到消息
materialize.min.js:6 Uncaught TypeError: Cannot read property '0' of null
at n.value (https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-alpha.3/js/materialize.min.js:6:104488)
at new n (https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-alpha.3/js/materialize.min.js:6:101364)
at Function.value (https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-alpha.3/js/materialize.min.js:6:11799)
at Function.value (https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-alpha.3/js/materialize.min.js:6:106244)
Codepen链接:Using 1.0.0-alpha3
HTML:
<div class="row">
<div class="col s12 m6">
Groups:
<div class="chips chips-autocomplete-groups"> </div>
</div>
</div>
JS:
var elem = document.querySelector('.chips-autocomplete-groups');
if (elem != null) {
var insChipAC = M.Chips.init(elem, {
placeholder: 'Enter a group',
secondaryPlaceholder: '+Group',
autocompleteOptions: {
data: {
'Alex': null,
'Brandy': null,
'Charlie': null
},
limit: Infinity,
minLength: 1
}
});
}
在 1.0.0-alpha2 版本中,我能够创建该组件 Codepen链接:Using 1.0.0-alpha2
答案 0 :(得分:0)