![](/img/trans.png)
[英]Wordpress wp_enqueue_script function not working, javascript file not loading
[英]Wordpress wp_enqueue_script not loading up on Front-End
我目前正在使用完全相同的方法加載3個腳本。 但是,其中兩個正在工作,而另一個則沒有。 我已經多次檢查代碼中是否有錯誤,但一無所獲。 我不明白為什么第三個腳本無法加載。
public function scripts() {
wp_register_script(
'global',
get_template_directory_uri() . '/assets/js/global.min.js',
array( 'jquery' ),
$version,
true
);
wp_enqueue_script( 'global' );
然后像這樣鈎住:
add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );
這工作得很好。 然后,我添加下一個函數,它不會加載:
public function map_scripts() {
global $version;
wp_register_script(
'map',
get_template_directory_uri() . '/assets/js/map.min.js',
array( 'jquery' ),
$version,
true
);
wp_enqueue_script( 'map' );
同樣,這也與“全局”掛鈎到相同的構造函數中,例如:
add_action( 'wp_enqueue_scripts', array( $this, 'map_scripts' ) );
我試過將“地圖”腳本移到與“全局”相同的公共函數中,但仍然無法加載。
有人有任何線索嗎?
我已經解決了這個問題。 我進行了一些文件重組,並正在編輯一個文件,該文件被重復的文件覆蓋。
我的錯!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.