【发布时间】:2019-09-17 17:47:23
【问题描述】:
我在 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/app/code/TEXT/Smsnotifications/view/adminhtml/web/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/app/code/TEXT/Smsnotifications/view/adminhtml/layout/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>
预期结果:启用短信通知模块后,另一个名为隐藏价格的模块应该可以正常工作。
实际结果:启用短信通知模块后,隐藏价格在 Magento 2 的管理仪表板中没有打开标签。
【问题讨论】:
-
Uncaught ReferenceError: jQuery is not defined - 通常表示未加载 jquery 库。从 CDN 包含它 -
-
确保包含 jquery 脚本
-
你能详细说明一下吗?
-
我已经在/domain_name/app/code/TEXT/Smsnotifications/view/adminhtml/layout/default.xml中添加了
-
页面>
标签: jquery error-handling requirejs magento2