我正在使用一个名为SweetAlert的库。我想在用户关闭模态后加载一个函数。
我当前的代码:
Swal.fire({
imageUrl: 'https://placeholder.pics/svg/600x600',
imageWidth: 600,
imageHeight: 600,
confirmButtonText: 'Jai compris'
}).then(('load', function(event){
var $this = $(this);
$this.text('...');
var $imageSection = $this.closest('.image-section');
var $colorThiefOutput = $imageSection.find('.color-thief-output');
var $targetimage = $imageSection.find('.target-image');
showColorsForImage($targetimage, $imageSection);
})
);
console.log:
the variables are not defined
单击按钮即可使用的代码:
Swal.fire({
imageUrl: 'https://placeholder.pics/svg/600x600',
imageWidth: 600,
imageHeight: 600,
confirmButtonText: 'jai compris'
}).then((result) => {
$('.run-functions-button').click('load', function(event) {
//Swal.fire('Any fool can use a computer')
var $this = $(this);
$this.text('...');
var $imageSection = $this.closest('.image-section');
var $colorThiefOutput = $imageSection.find('.color-thief-output');
var $targetimage = $imageSection.find('.target-image');
showColorsForImage($targetimage, $imageSection);
});
});
我的问题是为什么我的变量没有定义?单击按钮是加载功能的义务吗?
答案 0 :(得分:0)
Swal.fire({
imageUrl: 'https://placeholder.pics/svg/600x600',
imageWidth: 600,
imageHeight: 600,
confirmButtonText: 'Jai compris'
}).then(('load', function(event){
var $this = $('.run-functions-button');
$this.text('...');
var $imageSection = $this.closest('.image-section');
var $colorThiefOutput = $imageSection.find('.color-thief-output');
var $targetimage = $imageSection.find('.target-image');
showColorsForImage($targetimage, $imageSection);
})
);