this.source 不是函数。 jquery-ui 错误

this.source is not a function. Error with jquery-ui

jQuery-ui 在尝试使用自动完成方法时抛出错误

jquery-ui.min.js:8 Uncaught TypeError: this.source is not a function
    at t.<computed>.<computed>._search (jquery-ui.min.js:8)
    at t.<computed>.<computed>._search (jquery-ui.min.js:6)
    at t.<computed>.<computed>.search (jquery-ui.min.js:8)
    at t.<computed>.<computed>.search (jquery-ui.min.js:6)
    at t.<computed>.<computed>.<anonymous> (jquery-ui.min.js:8)
    at i (jquery-ui.min.js:6)

这是我的代码

$.get('https:/{{pretend there is a proper url here}}/hygiene.php', {op: 'search', business: val}, (res) => {
    res = JSON.parse(res);
    var businesses = res.map(r => {return r.business})

    $('#search-form').autocomplete({
        sources: businesses,
        appendTo: '#search-form'
    })
})

op 和 business 只是参数 required 从 API 开始工作。 API 有效,调用没有任何问题。 调用 return 是一个 json 业务字符串(因此 JSON.parse) 在已解析的数组上调用地图 return 只有企业名称,因为这是我想在自动完成中显示的名称。

搜索表单是文本输入

<input type='text' id='search-form'/>

我很确定这是 jQuery 的问题,而不是我的代码。 使用: https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js cdn

如有任何帮助,我们将不胜感激

应该是source不是sources

https://codepen.io/ernerock/pen/ByoqVo

$(function() {
    var availableTags = [
      "Rock",
      "Rap",
      "Trova",
      "Blues",
      "Country",
      "Folk",
      "Jass",
      "POP",
      "Electronic"
    ];
    $( "#tags" ).autocomplete({
      source: availableTags
    });
  });