gpt4 book ai didi

javascript - jQuery 错误导致 imageMapper 无法工作

转载 作者:行者123 更新时间:2023-12-03 01:52:35 25 4
gpt4 key购买 nike

我遇到了第三方脚本无法运行的问题。我得到的错误是:

"Uncaught TypeError: jQuery(...).imageMapper is not a function"

我尝试过多次修复此问题,但似乎没有效果。非常感谢任何帮助或想法。下面是脚本:

(function() {
var mapper_63_loadScript = function(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
};

var mapper_63_execute_scripts = function() {
jQuery('.imagemapper63-wrapper').imageMapper({
itemOpenStyle: 'click',
itemDesignStyle: 'responsive',
responsiveWidth: 600,
transformSmall: 1,
oldResponsive: 0,
animateOther: 1000,
pinScalingCoefficient: 1,
advancedPinOptions: true,
pinClickAction: "content",
pinHoverAction: "my_content",
useTransitions: '1',
animationDuration: 170,
mapOverlay: true
});
};

if ((typeof jQuery === 'undefined') || (parseInt(jQuery.fn.jquery) === 1 && parseFloat(jQuery.fn.jquery.replace(/^1\./, "")) < 9.1)) {
mapper_63_loadScript('//code.jquery.com/jquery-2.2.3.min.js', function() {
mapper_63_loadScript('https://easy-image-mapper.herokuapp.com/shopify_image_mapper.js?shop=mustaevusa.myshopify.com', function() {
mapper_63_execute_scripts();
});
});
} else {
mapper_63_loadScript('https://easy-image-mapper.herokuapp.com/shopify_image_mapper.js?shop=mustaevusa.myshopify.com', function() {
mapper_63_execute_scripts();
});
}
})();

最佳答案

将对 mapper_63_execute_scripts(); 的调用移至第 7 行的就绪状态处理程序内部。

您正尝试在该代码在浏览器中可用之前调用该代码。

关于javascript - jQuery 错误导致 imageMapper 无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50353037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com