我想将 Spine 2d 嵌入到 Reactjs 应用程序中,当我阅读 Spine 文档时,他们提供从“@esotericsoftware/spine-player”导入脊椎;但我渲染应用程序它发出错误:尝试导入错误:'@esotericsoftware/spine-player'不包含默认导出(导入为'spine')。
我的代码:
import React from 'react';
import spine from '@esotericsoftware/spine-player';
const Character = () => {
var jsonUrl = 'assets/Vi.json';
var atlasUrl = 'assets/Vi.atlas';
new spine.SpinePlayer('player-container', {
jsonUrl: jsonUrl,
atlasUrl: atlasUrl,
animation: 'jump',
premultipliedAlpha: true,
backgroundColor: '#cccccc',
viewport: {
debugRender: true,
},
showControls: true,
});
return <div id="player-container"></div>;
};