我正在使用vue-js,并编写了一些外部JavaScript代码。 JS仅在刷新页面时起作用。 但是,在单页应用程序中,无需刷新页面。 如何在不刷新页面的情况下应用JS? 贝娄是我的JS代码,需要刷新页面才能工作。
$('.toggle_description').click(function () {
description = $(this).prev();
description.toggle();
if (description.css('display') == 'none') {
$(this).html('نمایش');
$(this).removeClass('btn-primary').addClass('btn-success');
} else {
$(this).html('پنهان');
$(this).removeClass('btn-success').addClass('btn-primary');
// $(this).removeClass('btn-primary').addClass('btn-success');
}
});