php - jQuery 没有在 Wordpress 上定义-smoothstate Js
问题描述
我正在尝试将 smoothState.js 安装到我的 wordpress 主题中。它不工作,在调试时,我看到了这个错误——“jQuery 没有定义”。这是在我复制过来的 smoothState.js 文件中。
谁能帮我这个?我是否错误地安装了文件?我尝试在函数之后添加(jQuery)注释,但它仍然无法正常工作。感谢帮助!错误是针对下面的这个特定功能
/*!
* smoothState.js is jQuery plugin that progressively enhances
* page loads to behave more like a single-page application.
*
* @author Miguel Ángel Pérez reachme@miguel-perez.com
* @see http://smoothstate.com
*
*/
(function (factory) {
'use strict';
if(typeof module === 'object' && typeof module.exports === 'object') {
factory(require('jquery'), window, document);
} else {
factory(jQuery, window, document);
}
解决方案
看起来 smoothState.js 是在 jQuery 准备好之前加载的。
您如何将 smoothState 添加到您的页面?使用 wp_enqueue_script?
另外,smoothState 是如何在 JS 中加载的?
此链接可能会对您有所帮助https://webdesign.tutsplus.com/tutorials/how-to-integrate-smoothstatejs-into-a-wordpress-theme--cms-26610
推荐阅读
- sqlalchemy - 统计关联表中实体被引用的次数
- node.js - 在 Node.JS 中使用 Jest 模拟/存根一个类
- javascript - Firefox:有没有替代 .css("zoom")
- html - Bootstrap 表:是否可以让两行表成为移动友好的两列表?
- css - 使用 resizeMode=cover 在本机反应中显示图像,但我想切掉底部而不是顶部
- mongodb - 有没有办法对mongodb中的列顺序进行排序?
- r - 如何在 R 中循环使用两个列表
- c# - 如何从引用库的项目中获取变量?
- google-cloud-platform - (GCloud SQL) 有没有办法通过 CLI 或 API 选择加入维护通知?
- typescript - 如何在运行时将参数传递给 TypeScript 装饰器?