Spine 和 Reactjs 问题错误 @esotericsoftware/spine-player' 不包含默认导出(导入为 'spine')
Spine and Reactjs issues error @esotericsoftware/spine-player' does not contain a default export (imported as 'spine')
我想将 Spine 2d 嵌入到 Reactjs 应用程序中,
当我阅读 Spine 文档时,他们提供了 import spine from '@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>;
};
在我的案例中,我是这样解决这个问题的。 spine-player中没有名为spine的导出成员
import React from 'react';
import { SpinePlayer } from '@esotericsoftware/spine-player';
const Character = () => {
var jsonUrl = 'assets/Vi.json';
var atlasUrl = 'assets/Vi.atlas';
new SpinePlayer('player-container', {
jsonUrl: jsonUrl,
atlasUrl: atlasUrl,
animation: 'jump',
premultipliedAlpha: true,
backgroundColor: '#cccccc',
viewport: {
debugRender: true,
},
showControls: true,
});
return <div id="player-container"></div>;
};
我想将 Spine 2d 嵌入到 Reactjs 应用程序中, 当我阅读 Spine 文档时,他们提供了 import spine from '@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>;
};
在我的案例中,我是这样解决这个问题的。 spine-player中没有名为spine的导出成员
import React from 'react';
import { SpinePlayer } from '@esotericsoftware/spine-player';
const Character = () => {
var jsonUrl = 'assets/Vi.json';
var atlasUrl = 'assets/Vi.atlas';
new SpinePlayer('player-container', {
jsonUrl: jsonUrl,
atlasUrl: atlasUrl,
animation: 'jump',
premultipliedAlpha: true,
backgroundColor: '#cccccc',
viewport: {
debugRender: true,
},
showControls: true,
});
return <div id="player-container"></div>;
};