Anime.js 使用 Wordpress:模块未定义

Anime.js with Wordpress: module is not defined

我用 anime.js 和纯 HTML、CSS 和 JS 在本地制作了一些动画。 现在我需要在基于 wordpress 的站点中实现这些动画。

不幸的是,我收到错误 module is not defined。它指的是 anime.js 文件中的最后一行 module.exports = anime;.

我真的不太了解 Wordpress 开发,但我知道如何排队脚本(至少我认为我知道)

这是我调用 anime.js 的 functions.php 文件和我的 js 文件中的代码,尽管我什至不知道这个错误是否与我对文件的排队方式有关。

function load_my_scripts() {
    wp_register_script('animejs', get_template_directory_uri() . "/js/anime.js", array(), '', true );
    wp_enqueue_script('animejs');
    wp_register_script('scriptjs', get_template_directory_uri() . "/js/script.js", array('animejs'), '', true );
    wp_enqueue_script('scriptjs');
}
add_action('init', 'load_my_scripts');  

出现问题的站点是这个:http://www.provokatur.at/

非常希望有人能帮帮我,谢谢

如果您确定您的代码是正确的,请不要忘记在页面中添加<?php get_footer(); ?>

编辑: 我尝试在我的主题中使用 animejs,这段代码对我有用

function load_my_scripts() {
wp_register_script('animejs', 'https://cdnjs.cloudflare.com/ajax/libs/animejs/2.2.0/anime.min.js');
wp_enqueue_script('testscript', get_template_directory_uri(). '/js/test.js', array('animejs'), '', true);
}

add_action ('wp_enqueue_scripts', 'load_my_scripts');

我想通了。

我不再排队 anime.js 文件,我只是将其注册为:

wp_register_script('animejs', 'https://cdnjs.cloudflare.com/ajax/libs/animejs/2.2.0/anime.min.js');

在那之后动画就没有被执行,我所做的就是添加

来解决这个问题
  jQuery(document).ready(function($){
        //Code goes here
  })

显然这是用jQuery执行动画...虽然我真的不明白这背后的原因,但我仍然希望我的解释对一些人有所帮助。