简体   繁体   English

为什么Javascript无法在此WordPress插件上加载?

[英]Why is the Javascript not loading on this WordPress plugin?

I have looked over carefully at the scripts file for a WordPress plugin I am developing and I also looked at a similar post: 我仔细查看了我正在开发的WordPress插件的脚本文件,并且还看了类似的文章:

javascript file not working when linked from HTML 从HTML链接时,javascript文件不起作用

but the answer above has not worked either. 但是上面的答案也没有用。 I am not sure why the javascript file is not loading. 我不确定为什么无法加载javascript文件。

Here is the includes/newsletter-subscriber-scripts.php: 这是includes / newsletter-subscriber-scripts.php:

<?php

// Add Scripts
function ns_add_scripts(){
        wp_enqueue_style('ns-main-style', plugins_url().'/newsletter-subscriber/css/style.css');
        wp_enqueue_script('ns-main-script', plugins_url().'/newsletter-subscriber/js/main.js');
}

add_action('wp_enqueue_scripts', 'ns_add_scripts');

Here is the javascript file that is not loading in /newsletter-subscriber/js/main.js: 这是未在/newsletter-subscriber/js/main.js中加载的javascript文件:

alert('Linked');

Did you check it out that its enqueuing in front end you can see script tag in your HTML output? 您是否检查过它的前端排队,可以在HTML输出中看到脚本标签? of its coming than might be your browser java-script is off. 它的到来比您的浏览器Java脚本已关闭。 check it or you can add link to your site so than someone can debug it 检查它,或者您可以将链接添加到您的站点,以便有人可以对其进行调试

thank you 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM