enter image description here我正在以WordPress主题调用我的外部Js文件,但它显示了一些错误且无法正常工作
我做了可能的方法,但是没有用。
function creative_resources() {
wp_enqueue_style('style', get_stylesheet_uri(), '', 1.0);
wp_enqueue_script('script', get_template_directory_uri().'/js/main.js', array('jquery'), 1.1, true);
wp_enqueue_script('script-jqlib', get_template_directory_uri().'js/jquery-1.9.0.min.js', array('jquery'), 1.1, true);
}
add_action('wp_enqueue_scripts', 'creative_resources');
我只想要wp主题中的粘滞菜单,该菜单从main.js文件调用。调用了Main.js文件,但显示了一些错误,并且jq库无法加载。...
Uncaught TypeError: $ is not a function
at main.js?ver=1.1:2
Failed to load resource: the server responded with a status of 404 (Not Found)jquery-1.9.0.min.js:1
答案 0 :(得分:2)
您应将main.js
文件修改为:
jQuery(document).ready(function($) {
// Your Code that uses jQuery's $ can follow here.
});
和https://crunchify.com/how-to-fix-wordpress-uncaught-typeerror-is-not-a-function-jquery-error/