相关疑难解决方法(0)

如何在 astro 中将服务器变量传递给客户端 JS?

我找到了这个github) google auth 的 html 起始页,我想将其制作成 astro 组件。我想将其转换为.astro文件,并能够从后端传递 CLIENT_ID 和 API_KEY 的变量。我

这是来自谷歌的 HTML 代码:

<!DOCTYPE html>
<html>
  <head>
    <title>Google Calendar API Quickstart</title>
    <meta charset="utf-8" />
  </head>
  <body>
    <p>Google Calendar API Quickstart</p>

    <!--Add buttons to initiate auth sequence and sign out-->
    <button id="authorize_button" onclick="handleAuthClick()">Authorize</button>
    <button id="signout_button" onclick="handleSignoutClick()">Sign Out</button>

    <pre id="content" style="white-space: pre-wrap;"></pre>

    <script type="text/javascript">
      /* exported gapiLoaded */
      /* exported gisLoaded */
      /* exported handleAuthClick */
      /* exported handleSignoutClick */

      // TODO(developer): Set to …
Run Code Online (Sandbox Code Playgroud)

astrojs

17
推荐指数
1
解决办法
1万
查看次数

标签 统计

astrojs ×1