wangzhibo
2023-10-31 9da39812105bfc387db3b3b7c4896983e03d247d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!doctype html>
<html lang="en">
 
<head>
  <meta charset="utf-8" />
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
  <meta name="theme-color" content="#000000" />
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
  <link rel="apple-touch-icon" href="/pwa-192x192.png" />
 
  <title>metacubexd</title>
</head>
 
<body>
  <noscript>You need to enable JavaScript to run this app.</noscript>
  <button id="btn_play" onclick="javascript:callCSharpMethod()">测试(From JS to C#)</button>
 
  <div id="root" style="display: contents"></div>
  <script>
    // 测试在Web中调用C#的方法
    function callCSharpMethod() {
      console.log("a test from web page js:")
      window.backendSharp.showAlertMsg("来自JS的调用");
    }
   
 
    // 测试C#调用JS的方法,只传递一个普通的字符串
    function displayMessage(message) {
      alert(message);
    }
  </script>
  <script src="/src/main.tsx" type="module"></script>
</body>
 
</html>