Wordpress 和 GSAP TweenLite 的问题
Trouble with Wordpress and GSAP TweenLite
我正在创建我的第一个 WordPress 主题,我正在尝试集成 TweenLite 库,但它不起作用。我不确定错误在哪里。
首先在我的子主题的 function.php 文件中我有:
add_action('wp_enqueue_scripts', 'custom_theme_scripts');
function custom_theme_scripts() {
wp_register_script('GSAP', 'http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js', true);
wp_register_script('Animations', get_template_directory_uri() . '/animation.js', true);
}
第一个脚本是 TweenLite,第二个是我的自定义脚本,我正在使用它测试是否有效。
这是我的测试脚本代码:
var logo = document.getElementById("logo");
TweenLite.to(logo, 1.5, { width: 500 });
wp_register_script 还不够。
您必须在使用 wp_enqueue_script();
注册后将其入队
add_action('wp_enqueue_scripts', 'custom_theme_scripts');
function custom_theme_scripts() {
wp_register_script('GSAP','http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js', true);
wp_register_script('Animations', get_template_directory_uri() . '/animation.js', true);
wp_enqueue_script('GSAP');
wp_enqueue_script('Animations');
}
我正在创建我的第一个 WordPress 主题,我正在尝试集成 TweenLite 库,但它不起作用。我不确定错误在哪里。
首先在我的子主题的 function.php 文件中我有:
add_action('wp_enqueue_scripts', 'custom_theme_scripts');
function custom_theme_scripts() {
wp_register_script('GSAP', 'http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js', true);
wp_register_script('Animations', get_template_directory_uri() . '/animation.js', true);
}
第一个脚本是 TweenLite,第二个是我的自定义脚本,我正在使用它测试是否有效。
这是我的测试脚本代码:
var logo = document.getElementById("logo");
TweenLite.to(logo, 1.5, { width: 500 });
wp_register_script 还不够。 您必须在使用 wp_enqueue_script();
注册后将其入队add_action('wp_enqueue_scripts', 'custom_theme_scripts');
function custom_theme_scripts() {
wp_register_script('GSAP','http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js', true);
wp_register_script('Animations', get_template_directory_uri() . '/animation.js', true);
wp_enqueue_script('GSAP');
wp_enqueue_script('Animations');
}