<!-- 引入 React 代码,并使用 Babel 转译 -->
<script type="text/babel">
function App() {
React.useEffect(() => {
<!-- 在 React 中直接调用 Axue 初始化 -->
<!-- 但如果在上面的 <script> 标签中已经初始化了 Axue,就不需要再次调用 -->
}, []); <!-- 确保初始化只在组件加载时调用一次 -->
return (
<div className="App">
<h1>Welcome to React with Axue</h1>
<div>
<!-- 使用 Axue 组件 -->
<axue-logo-close></axue-logo-close>
</div>
<button onClick={() => window.axueAPI.showTip.send('Hello, Axue from React!')}>
Show Tip
</button>
</div>
);
}
<!-- 渲染 React 应用 -->
ReactDOM.render(<App />, document.getElementById('root'));
</script>