【问题标题】:Add jquery to Mganto pages inside admin panels [wysiwig editor]将 jquery 添加到管理面板内的 Magento 页面 [所见即所得编辑器]
【发布时间】:2020-11-08 14:38:48
【问题描述】:

如何在 magento2 页面中添加 jQuery 代码?例如,我有一个“联系我们”页面。所以我可以通过

编辑联系我们页面内的内容

登录管理面板

admin -> content -> Pages -> Contact us

我想添加一些 jQuery 代码。

所以我写

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
  <script>
   jQuery(function($){
    $(".mybox").on("click", function(){
             MY CODE *******
       });
 });
</script>

这里的问题是:我必须打电话给&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"&gt;

否则将无法正常工作。我该如何解决这个问题?

即。 如何在所见即所得编辑器中添加 jquery 代码

【问题讨论】:

    标签: magento magento2 magento-1.8


    【解决方案1】:

    Magento 2 使用需要 js

    尝试使用

    <script>
    require([
        'jquery'
    
    ], function ($) {
        $(".mybox").on("click", function () {
            console.log('your code starts here');
    
            console.log('your code ends here');
        });
    });
    </script>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-11
      • 1970-01-01
      • 2013-03-23
      • 1970-01-01
      • 2015-03-17
      • 2012-02-27
      • 2020-06-17
      • 2016-01-13
      相关资源
      最近更新 更多