指导我执行此代码,在每个建议的示例(href =“ http://127.0.0.1:8000/usa/”)上,我都具有Materializecss的自动完成功能或带有超链接(href)的自动建议文本框。 谢谢
[
{
"id": 1,
"title": "usa",
"text": "coucou",
"slug": "usa"
}
]
<div class="input-field">
<input type="text" id="autocomplete-input" class="autocomplete">
<label for="autocomplete-input">Autocomplete</label>
</div>
$(document).ready(function() {
$(function() {
$.ajax({
type: 'GET',
url: 'http://127.0.0.1:8000/',
success: function(response) {
var countryArray = response;
var countryList = {};
for (var i = 0; i < countryArray.length; i++) {
countryList[countryArray[i].title] = countryArray[i].null;
}
$('input.autocomplete').autocomplete({
data: countryList,
limit: 5,
minLength: 3
});
}
});
});
});