首页 > 解决方案 > React 应用程序在 Safari 浏览器中不起作用?语法错误

问题描述

document.querySelector("[rel='icon'").setAttribute('href', {Favicon});

(function($) {
    $(document).ready(function() {
        $('body').on('click', '.news-text img', function(e) {
            let src = $(this).attr('src');
            const modal = $('#lightBoxModal');
            modal.css('display', 'block');
            modal.find('img').remove();
            modal.find('.modal-content').append('<img src="' + src + '" alt="">');
        });

        $('#lightBoxModal, #lightBoxModal .close-icon').on('click', function() {
            const modal = $('#lightBoxModal');
            modal.find('img').remove();
            modal.css('display', 'none');
        });
    });
})(jQuery);

SyntaxError(DOM 异常 12):字符串与预期的模式不匹配。
React 应用程序网站在 safari 中不起作用!
我该如何解决这个问题?

标签: javascriptjqueryreactjs

解决方案


似乎您在陈述的末尾缺少一个括号:

document.querySelector("[rel='icon'") // Original
document.querySelector("[rel='icon']") // <-- Fixed

推荐阅读