如何解决此错误:未捕获的ReferenceError:未定义jQuery

问题描述 投票:0回答:1

我在Magento 2中使用该模块进行SMS通知,这会影响用于隐藏价格的另一个模块。当我尝试打开隐藏价格仪表板时,我收到此错误。

Uncaught ReferenceError: jQuery is not defined
    at smsnotification.js?v=6688:1
jquery-ui-1.9.2.js:14075 Uncaught TypeError: ui.jqXHR.success is not a function
    at $.<computed>.<computed>.tabsbeforeload (jquery-ui-1.9.2.js:14075)
    at HTMLDivElement.handlerProxy (jquery-ui-1.9.2.js:739)
    at HTMLDivElement.dispatch (jquery.min.js?v=6688:3)
    at HTMLDivElement.q.handle (jquery.min.js?v=6688:3)
    at Object.trigger (jquery.min.js?v=6688:4)
    at Object.jQuery.event.trigger (jquery-migrate.js:493)
    at HTMLDivElement.<anonymous> (jquery.min.js?v=6688:4)
    at Function.each (jquery.min.js?v=6688:2)
    at jQuery.fn.init.each (jquery.min.js?v=6688:2)
    at jQuery.fn.init.trigger (jquery.min.js?v=6688:4)

我试图添加requirejs代码,但它没有工作。我在这里分享js文件代码。来自TEXT_Smsnotifications模块。 cpanel中的路径是

domain_file /应用程序/代码/文本/ Smsnotifications /视图/ adminhtml /网络/ JS / smsnotification.js

'''

 jQuery(document).ready(function(){
   jQuery(".click-me").click(function(){

   jQuery("#popup-mpdal").addClass('open-popop');
 });

   jQuery(".close-popop").click(function(){

   jQuery("#popup-mpdal").removeClass('open-popop');
 });});

'''我还在脚本中添加了min.js. DOMAIN_NAME /应用程序/代码/文本/ Smsnotifications /视图/ adminhtml /布局/ default.xml中

<?xml version="1.0"?>
     <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
       <head>
          <css src="TEXT_Smsnotifications::css/bootstrap.min.css"/> 
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" src_type="url" />
          <script src="TEXT_Smsnotifications::js/smsnotification.js" />
          <css src="TEXT_Smsnotifications::css/smsnotification.css" />
       </head> 
     </page>

预期结果:启用SMS通知模块后,另一个名为Hide Price的模块应该可以正常工作。

实际结果:启用SMS通知模块后,Magento 2的管理仪表板中的隐藏价格未打开选项卡。

jquery error-handling requirejs magento2
1个回答
0
投票

您需要在任何其他相关脚本标记之前(在标题中)添加此项。

<script src="http://code.jquery.com/jquery-3.*.*.min.js"></script>

用你需要的JQuery版本替换*

© www.soinside.com 2019 - 2024. All rights reserved.