我想將此JavaScript代碼翻譯爲JSNI代碼。來自JSNI的外部函數調用不起作用
腳本導入
<script src="jquery-1.11.2.min.js"></script>
<script src="jquery.typeahead.min.js"></script>
<script src="autocompletetest/autocompletetest.nocache.js"></script>
腳本
$('#q').typeahead({
minLength: 1,
order: "asc",
group: true,
groupMaxItem: 6,
hint: true,
dropdownFilter: "All",
href: "https://en.wikipedia.org/?title={{display}}",
template: "{{display}}, <small><em>{{group}}</em></small>",
source: {
country: {
data: data.countries
},
capital: {
data: data.capitals
}
},
...
要
$doc.getElementsByClassName("q").typeahead({
...
})
但我發現了這個錯誤:
@com.citi.sevi.client.AutocompleteTest::loadJquery()([]): $doc.getElementsByClassName(...).typeahead is not a function
什麼導致這個錯誤?
歡迎來到堆棧溢出!我編輯了你的問題,使代碼更具可讀性,並希望得到更多人的幫助。祝你好運! –