【发布时间】:2018-01-26 10:32:36
【问题描述】:
我是打字稿的新手,我想知道如何在打字稿中编写以下代码。我的项目在 asp.net MVC 中。 这是我的代码:
$("#EmployeeCode").autocomplete({
source: function (request, response) {
$("#EmployeeCode").val('');
$.ajax({
url: '/Admin/Search/Country/' + request.term,
dataType: "json",
type: "GET",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data, function (item) {
return {
label: item,
val: item.split('-')[1],
}
}))
},
error: function (response) {
console.log(response.responseText);
},
failure: function (response) {
console.log(response.responseText);
}
});
},
select: function (e, i) {
// $(this).val(i.item.val);
$("#EmployeeCode").val(i.item.val);
},
minLength: 3
});
【问题讨论】:
-
嗯,根据您设置的打字稿规则,是有效的打字稿。如果您有需要类型的规则,则需要添加类型定义文件。如果您没有类型定义文件,您可以创建它们或作弊,然后到处乱扔
:any。
标签: javascript c# typescript asp.net-mvc-4 typescript2.0