WordPress page: Uncaught TypeError: $ is not a function

WordPress page: Uncaught TypeError: $ is not a function

我在 WordPress 页面中嵌入以下代码时遇到此错误。我找不到它有什么问题。

<script>
  jQuery(window).load(function($) {
    if ($(".default-hero .hero-image img").length) {
      console.log($(".default-hero .hero-image img").css("height"));
      // Hero image exits. Adjust the .default-hero .inside .row to the minimum height of the image.
      $(".default-hero .inside .row").css("min-height", $(".default-hero .hero-image img").css("height"));
    }
  });
</script>

load 不像 ready() 那样 return 引用 jQuery。它是不是函数的事件对象。

(function($){
  jQuery(window).load(function() {
    console.log($);
  });
})(jQuery);