我尝试从文件中的函数处理选择下拉列表onchange事件,但是我得到了异常。我的代码如下所示:
<div class="form-group">
<label asp-for="Region"></label>
<select id="Select" name="Region" asp-items="@Model.Region" class="form-control" onchange="site.action.address.loadTown()">
<option selected="selected" value="">Избери област</option>
</select>
<span asp-validation-for="Region" class="text-danger"></span>
</div>
<script src="~/files/js/Core/site.action.address.js"></script>
在文件中它就像:
(function (site, $, undefined) {
site.action.address = {};
let me = site.action.address;
me.loadTown = function () {
let test = "test";console.log(test);
};
})(window.site= window.site|| {}, jQuery);