页面全部代码
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/core@5/index.css" />
</head>
<body>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three/build/three.module.js",
"@photo-sphere-viewer/core": "https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/core@5/index.module.js"
}
}
</script>
<div id="viewer" style="width: 100vw; height: 95vh;"></div>
<script type="module">
import { Viewer } from '@photo-sphere-viewer/core';
var viewer = new Viewer({
container:'viewer',
panorama: 'https://photo-sphere-viewer-data.netlify.app/assets/sphere-cropped.jpg',
});
viewer.on("ready", function() {
alert("dddd");
console.log("It is ready");
});
</script>
</body>
</html>
`
网页F12报错
ncaught TypeError: viewer.on is not a function
如何能让 viewer.on('ready',function(){}成功使用