我有打字稿功能
这是功能代码
export class Step1{
constructor(){
this.begin_search();
this.results_ready();
}
private results_ready():void{
$(function() {
Filter.load_filter();
let loading_more_results = false;
let loading_more_offset = 0;
if ((gon.search['search_type'] === 'hotel') || (gon.search['search_type'] === 'package')) {
HotelResults.load_step_1_hotel_results();
} else {
AirResults.load_step_1_air_results();
}
if (gon.search['search_type'] === 'package') {
for (let i of Array.from($('.step_1_air_form'))) {
$('.tip', i).tooltipster({ contentAsHTML: true });
}
$('.step_1_air_form:not(.item_loaded) input[type=checkbox]').on('click', () =>
$('.step_1_hotel_form').each(function() {
return HotelResults.update_price_on_button_hotel($(this));
})
);
}
$('.topnav a').each(function() {
if ($(this).target === '') { $(this).target = '_blank'; }
});
$('.fancybox').fancybox();
$('.list_view').on('click', function() {
$('.img-selected').removeClass('img-selected');
$(this).parent().addClass('img-selected');
$('#filter_view').val('list');
FilterFunctions.onFilterChange();
return false;
});
$('.gallery_view').on('click', function() {
$('.img-selected').removeClass('img-selected');
$(this).parent().addClass('img-selected');
$('#filter_view').val('gallery');
FilterFunctions.onFilterChange();
return false;
});
$('.map_view').on('click', function() {
$('.img-selected').removeClass('img-selected');
$(this).parent().addClass('img-selected');
$('#filter_view').val('map');
FilterFunctions.onFilterChange();
return false;
});
$(window).scroll(function() {
if ($(".right_banner img").length > 0) {
let offset;
if ($('#header').css('position') === 'fixed') {
offset = 75;
} else {
offset = 15;
}
if (($(".right_banner img").css('position') === 'static') && ($(window).scrollTop() > ($(".right_banner").offset().top - offset))) {
$(".right_banner img").css("left", $(".right_banner").offset().left);
$(".right_banner img").css("top", offset);
$(".right_banner img").css("position", "fixed");
}
if (($(".right_banner img").css('position') === 'fixed') && ($(window).scrollTop() <= ($(".right_banner").offset().top - offset))) {
$(".right_banner img").css("position", 'static');
}
}
if ((($('#filter_view').length === 0) || ($('#filter_view').val() !== 'map')) && !loading_more_results && (($(window).scrollTop() + $(window).height()) > ($(document).height() - 1250))) {
let loading_more_results = true;
return Itinerary.loadMoreResults();
}
});
return $(window).resize(function() {
if ($(".right_banner img").css('position') === 'fixed') {
$(".right_banner img").css("position", 'static');
$(".right_banner img").css("left", $(".right_banner").offset().left);
return $(".right_banner img").css("position", "fixed");
}
});
});
};
}
我在像这样的webpack包中使用它
$(document).ready(()=&gt; { Translation.addDict(gon.translations); Track.initialize();
new Searchfield(); let step1 = new Step1(); if (!gon.search['searched']) { step1.begin_search(); step1.results_ready(); } /*if (gon && gon.search['id'] && $('.offer_hotel_addon').length > 0) { check_status(); }*/ });
但是当我运行网站时,我在控制台出现此错误
results_ready未定义
如果在第一个函数中定义了错误,为什么会出现此错误?
非常感谢帮助