2 回答

TA貢獻1843條經驗 獲得超7個贊
創建一個 React 組件來渲染阿拉丁天空圖(這樣其他地方就不會出現阿拉丁了)。然后,您可以在內部定義和配置aladin componentDidMount(如果您使用類組件)或React.useEffect(如果您使用鉤子)。
索引.html:
...
<head>
<link rel="stylesheet" href="https://aladin.u-strasbg.fr/AladinLite/api/v2/latest/aladin.min.css" />
<!-- you can skip the following line if your page already integrates the jQuery library -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.1.min.js" charset="utf-8"></script>
<!-- insert this snippet where you want Aladin Lite viewer to appear and after the loading of jQuery -->
<script type="text/javascript" src="https://aladin.u-strasbg.fr/AladinLite/api/v2/latest/aladin.min.js" charset="utf-8"></script>
</head>
...
阿拉丁.jsx:
const Aladin = () => {
React.useEffect(() => {
let aladin = A.aladin('#aladin-lite-div', { survey: 'P/DSS2/color', fov:60 })
aladin.setFov(1)
}, [])
return (
<div id='aladin-lite-div' style={{ width: '400px', height: '400px' }} />
)
}
export default Aladin
然后,在你想要渲染阿拉丁天空圖的任何地方:
import Aladin from './Aladin'
...
<Aladin />

TA貢獻1797條經驗 獲得超6個贊
let?aladin?=?window.A.aladin('#aladin-lite-div',?{?survey:?'P/DSS2/color',?fov:60?})
該函數A.aladin
無法直接調用,因為它是外部 JavaScript 函數。
- 2 回答
- 0 關注
- 152 瀏覽
添加回答
舉報