如何在 Google Apps 脚本中将 css 连接到 html

问题描述 投票:0回答:1

我正在尝试制作我的第一个 Google 应用程序。我的 HTML 文档包含 HTML 服务:最佳实践中概述的包含语句。

<html>
    <head>
        <base target="_top">
        <?!= include('stylesheet') ?>
    </head>
    <body>
       ...
    </body>

我的code.gs文件如下:

function doGet() {
   return HtmlService.createTemplateFromFile('BooksTS2.html')
  .evaluate();
}

我的样式表名为 stylesheet.html,出于测试目的非常简单:

<style>
   p {color: green;}
</style>

但是当我运行它时,我收到此错误消息:ReferenceError:“include”未定义。

html css google-apps-script
1个回答
11
投票

在示例中,他们创建了可重用函数 include(),您需要添加它

© www.soinside.com 2019 - 2024. All rights reserved.