如何在甜蜜警报2中使用window.screen.width

时间:2020-09-18 02:59:24

标签: javascript sweetalert2

这是我的JavaScript代码

    var modals = [];


modals.push({
    title: 'Welcome to Lumi FansPage !',
    text: 'This website requires desktop web resolution to experience its features',
});


modals.push({
    title: 'Checking your screen resolutions',
    text: 'Please wait',
    timer: 2500,
    onOpen: function () {
        swal.showLoading()
    }
}).then(function () {

});

function showLoading() {
    if ($(window).width() < 1080) {
        alert('Sorry, but your screen resolution cant feel all the features, please use the Desktop Version!' +
            ' Your resolution is ' +
            window.screen.width * window.devicePixelRatio + "x" + window.screen.height * window.devicePixelRatio);
    } else {
        alert('Congratulations, you can experience all of its features now! ' + ' Your resolution is ' + window.screen
            .width *
            window.devicePixelRatio + "x" +
            window.screen.height *
            window.devicePixelRatio);
    }
};


swal.queue(modals);

我想在检查屏幕分辨率后用window.screen.width显示屏幕分辨率,然后显示警报,但是在编写该代码后什么都没发生,那么如何在用此代码检查分辨率后显示警报?

modals.push({
    title: 'Checking your screen resolutions',
    text: 'Please wait',
    timer: 2500,
    onOpen: function () {
        swal.showLoading()
    }
}).then(function () {

})

请帮助我

0 个答案:

没有答案