php - 使用 jquery 脚本添加操作时如何修复 (T_CONSTANT_ENCAPSED_STRING)
问题描述
我正在尝试从头开始创建一个 wordpress 主题,但是在添加时
add_action('wp_enqueue_scripts', 'jquery');
在我得到的页面上弹出我的 js 脚本警报
解析错误:语法错误,意外'',1,真);' (T_CONSTANT_ENCAPSED_STRING),期待 ')'
对于那条线
function include_jquery() {
wp_deregister_script('jquery');
wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery3.3.1.min.js, '', 1, true);
add_action('wp_enqueue_scripts', 'jquery');
}
add_action('wp_enqueue_scripts', 'include_jquery');
我希望代码能够从我的 js 文件中显示我的警报。
$(document).ready(function() {
alert('test');
})
解决方案
错字。改变
wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery3.3.1.min.js, '', 1, true);
至
wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery3.3.1.min.js', '', 1, true);
推荐阅读
- c# - C# 使用 LINQ to XML 将 XML 元素解析为类列表
- ios - Swift:拖放委托 - 拖放到另一个文本视图时无法拖出文本视图
- flutter - Flutter 为 HTML 加载本地资源
- c - 操作系统会向设备请求中断吗?
- angular - 为应用程序中的所有输入设置默认指令
- postman - 检查 Postman 测试用例中的空值 .not.eql() 或 .not.equal() 不起作用
- apache-flink - Flink 如何使用从 Avro 输入数据推断出的模式创建表
- node.js - 从查询返回数据时,我们如何获取唯一 ID
- php - window.location.replace() 和 window.location 在 jquery 代码中不起作用
- c++ - 用于映射一对一关系的 STL 类型?