Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery magento 2未捕获类型错误:没有名为“的方法”;“开放式”;_Jquery_Bootstrap 4_Bootstrap Modal_Magento 2.3 - Fatal编程技术网

Jquery magento 2未捕获类型错误:没有名为“的方法”;“开放式”;

Jquery magento 2未捕获类型错误:没有名为“的方法”;“开放式”;,jquery,bootstrap-4,bootstrap-modal,magento-2.3,Jquery,Bootstrap 4,Bootstrap Modal,Magento 2.3,我使用的是magento 2.3版本。我制作了一个自定义模块。在自定义模块中,我需要2个弹出窗口(使用引导模式) 这是我的js代码- JS代码: define( [ 'jquery', 'Magento_Ui/js/modal/modal', 'jquery/jquery.cookie', ], function ($, Component) { 'use strict'; va

我使用的是magento 2.3版本。我制作了一个自定义模块。在自定义模块中,我需要2个弹出窗口(使用引导模式)

这是我的js代码-

JS代码:

define(


    [

        'jquery',
        'Magento_Ui/js/modal/modal',
        'jquery/jquery.cookie',
    ],


    function ($, Component) {

        'use strict';

        var mageJsComponent = function (data) {
            var getData = JSON.stringify(data);
            var jsongetData = JSON.parse(getData);
            var height_value = jsongetData["height"];
            var width_value = jsongetData["width"];
            var coockie_value = jsongetData["coockieexpire"];
            var coockie_value = coockie_value*3600;
            $(document).ready(
                function ($) {
                console.log("ageverification.phtml : document loaded");
                });
            var options = {
                type: 'popup',
                responsive: true,
                innerScroll: true,
                // buttons: [{}],
                modalClass: 'custom_age_verfication',
                responsiveClass: 'ageverification-poup'
            };
            $(document).keyup(function (e) {
                if (e.keyCode == 27) {
                    return false;
                }
            });

            $(document).ready(function () {
                $(document).mousedown(function (e) {
                    return true;
                });

                if ($.cookie('status') != 1) {
                    var ageconf = document.getElementsByClassName('ageconf');
                    if (ageconf.length > 0) {
                        if (document.getElementById("popup").classList.contains('ageconf')) {
                            $(document).mousedown(function (e) {
                                return false;
                            });
                        }
                    }


                   var mdl = jQuery('.age-pop-up').modal(options);
                    jQuery('.age-pop-up').modal('openModal');
                    // Click on enter button
                    $('#enter').click(function () {
                        if (coockie_value == "") {
                            coockie_value = 1;
                        }
                        $.cookie('status', '1', {
                            expires: +coockie_value
                        });
                        jQuery('.age-pop-up').modal('closeModal');
                        window.location.reload();
                        // detect safari browser
                        if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
                            window.location.reload();
                        }
                    });

                    $('#no').click(function () {
                        if (coockie_value == "") {
                            coockie_value = 1;
                        }
                        $.cookie('status', '0', {
                            expires: +coockie_value
                        });
                        var mdl = jQuery('.not-verify').modal();
                        jQuery('.not-verify').modal('openModal');
                        jQuery('.age-pop-up').modal('closeModal');
                        jQuery('.age-pop-up.not-verify').show();
                    });
                }
            });
            // end : pop-up  age verification content
        };
        return mageJsComponent;
    });
定义(
[
“jquery”,
“Magento_Ui/js/modal/modal”,
“jquery/jquery.cookie”,
],
函数($,组件){
"严格使用",;
var mageJsComponent=函数(数据){
var getData=JSON.stringify(数据);
var jsongetData=JSON.parse(getData);
var height_value=jsongetData[“height”];
var width_value=jsongetData[“width”];
var coockie_value=jsongetData[“coockieeexpire”];
var coockie_值=coockie_值*3600;
$(文件)。准备好了吗(
函数($){
log(“ageverification.phtml:已加载文档”);
});
变量选项={
键入:“弹出窗口”,
回答:是的,
是的,
//按钮:[{}],
modalClass:“自定义年龄验证”,
响应类:'AgeVerificationPoup'
};
$(文档).keyup(函数(e){
如果(e.keyCode==27){
返回false;
}
});
$(文档).ready(函数(){
$(文档).mousedown(函数(e){
返回true;
});
如果($.cookie('status')!=1){
var ageconf=document.getElementsByClassName('ageconf');
如果(ageconf.length>0){
if(document.getElementById(“popup”).classList.contains('ageconf')){
$(文档).mousedown(函数(e){
返回false;
});
}
}
var mdl=jQuery('.age弹出框').model(选项);
jQuery('.age弹出框').modal('openModal');
//点击回车按钮
$('#输入')。单击(函数(){
如果(coockie_值==“”){
coockie_值=1;
}
$.cookie('状态','1'{
过期:+coockie_值
});
jQuery('.age弹出框').modal('closeModal');
window.location.reload();
//检测safari浏览器
if(navigator.userAgent.search(“Safari”)>=0&&navigator.userAgent.search(“Chrome”)<0){
window.location.reload();
}
});
$('#否')。单击(函数(){
如果(coockie_值==“”){
coockie_值=1;
}
$.cookie('状态','0'{
过期:+coockie_值
});
var mdl=jQuery('.not verify').modal();
jQuery('.not verify').modal('openModal');
jQuery('.age弹出框').modal('closeModal');
jQuery('.age弹出窗口。未验证').show();
});
}
});
//结束:弹出年龄验证内容
};
返回组件;
});
phtml文件:

<div class="outer-bg">
    <div id="popup" class="pop-cont age-pop-up ageconf">
        <div class="verify">
            <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId($popupblockid)->toHtml(); ?>
                <div class="buttons-set">
                    <a id="enter" class="button valid-age" title="<?php echo $agreebtn; ?>" href="#"><?php echo $agreebtn; ?></a>
                    <h4>Or</h4>
                    <a id="no" class="button not-valid-age" title="<?php echo $disagreebtn; ?>" href="#"><?php echo $disagreebtn; ?></a>
                </div>
        </div>
    </div>
    <div id="popup1" class="not-verify age-pop-up">
        <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId($disagreepopupblockid)->toHtml(); ?>
    </div>
</div>
在控制台中,我在第三次刷新页面时遇到此错误:

uncaughttypeerror:没有名为“openModal”的方法
在HTMLDEVELENT。(bootstrap.bundle.js:4795)
在Function.each(jquery.js:370)
在jQuery.fn.init.each(jQuery.js:137)
在jQuery.fn.init.\u jQueryInterface[作为模态](bootstrap.bundle.js:4783)
在HTMLDocument。(ageverification.js:69)
失火(jquery.js:3232)
在Object.add[完成时](jquery.js:3291)
位于jQuery.fn.init.jQuery.fn.ready(jQuery.js:3542)
在mageJsComponent(ageverification.js:38)
在main.js:31

我在刷新时显示1个模式,在弹出窗口中,有2个按钮,一个用于确认,第二个用于退出,如果单击确认按钮,则应将其重定向到主页,或者如果单击退出,则显示第二个弹出窗口。

可能相关,您是否找到任何可能的解决方案?编辑etc/view.xml对我不起作用。@MarceloRodovalho不,我尝试了一个弹出窗口,然后出错了
Uncaught TypeError: No method named "openModal"
    at HTMLDivElement.<anonymous> (bootstrap.bundle.js:4795)
    at Function.each (jquery.js:370)
    at jQuery.fn.init.each (jquery.js:137)
    at jQuery.fn.init._jQueryInterface [as modal] (bootstrap.bundle.js:4783)
    at HTMLDocument.<anonymous> (ageverification.js:69)
    at fire (jquery.js:3232)
    at Object.add [as done] (jquery.js:3291)
    at jQuery.fn.init.jQuery.fn.ready (jquery.js:3542)
    at mageJsComponent (ageverification.js:38)
    at main.js:31