引入方式类似prism,由于使用概率较大,因此在主题模板函数中进行全局引入:
// Function to add APlayer.mini.css and APlayer.mini.js to the site
function add_APlayer() {
wp_register_style(
'APlayerCSS', // handle name for the style
get_stylesheet_directory_uri() . '/APlayer.css' // location of the file
);
wp_register_script(
'APlayerJS', // handle name for the script
get_stylesheet_directory_uri() . '/APlayer.js' // location of the file
);
// Enqueue the registered style and script files
wp_enqueue_style('APlayerCSS');
wp_enqueue_script('APlayerJS');
}
add_action('wp_enqueue_scripts', 'add_APlayer');
然后采用 APlayer官方文档 中描述的方式引入:
<div id="aplayer">
</div>
<script>
const ap = new APlayer({
container: document.getElementById('aplayer'),
audio: [{
name: '',
artist: '',
url: '',
cover: ''
}]
});
</script>
发表回复