javascript - JavaScript 和警报弹出没有在 wordpress 中运行,即使 gulpfile.js 运行
问题描述
在functions.php中我有以下代码
function university_files()
{
wp_enqueue_script('main-university-js', get_theme_file_uri('/js/scripts-bundled.js'), array('jquery'), '1.0', true);
}
add_action('wp_enqueue_scripts', 'university_files');
**and in scripts.js i have code like this**
// 3rd party packages from NPM
import $ from 'jquery';
import slick from 'slick-carousel';
// Our modules / classes
import Search from './modules/Search';
import MyNotes from './modules/MyNotes';
// Instantiate a new object using our modules/classes
var search = new Search();
var mynotes = new MyNotes();
alert("this is a js script");
**but whenever i try to reload page alert msg wont come**
**i have installed package json and the following is the gulpfile.js**
var gulp = require('gulp');
// Watch for file updates
gulp.task('watch', function () {
gulp.watch('js/**/*.js').on('change', function (file) {
//console.log(file);
console.log(('JS changed' + ' (' + file.path + ')'));
});
});
文件结构和 gulp watch 运行镜像
但是当我尝试运行 gulp 时,它会正确执行,但是在刷新 wordpress 主页后,我不会收到写在 scripts.js 文件中的警报消息(它在 js 文件夹下以及 bundledscripts.js 下)
解决方案
推荐阅读
- python - 我们是否使用自己的数据正确更新了现有的 gemsim 模型?
- java - 为什么在右子数组的情况下必须做 (k-pivot+left-1) 同时在数组中找到第 k 个最小元素?
- pdf - 以编程方式重命名 ocrmyfile 中的文件
- linux - 从 Instant Client 在 RHEL7 上安装 Oracle SQL*Loader SQLLDR
- c++ - 如何使用 Mingw-w64 和 Intel MKL 编译 MATLAB MEX 文件
- python - 安装 pipenv 后没有这样的文件或目录
- python - valueerror: 时间数据与 pandas 的数据框不匹配
- java - 创建一个测试器类
- python - 使用具有不同分位数的 medianBlur
- python - 如何让输入部分在此代码中被询问一次?