HGa*_*ble 2 html css google-apps-script
我正在尝试制作我的第一个Google App。我有我的HTML文档,该文档包含HTML服务:最佳做法中概述的include语句。
<html>
<head>
<base target="_top">
<?!= include('stylesheet') ?>
</head>
<body>
...
</body>
Run Code Online (Sandbox Code Playgroud)
我的code.gs文件如下:
function doGet() {
return HtmlService.createTemplateFromFile('BooksTS2.html')
.evaluate();
}
Run Code Online (Sandbox Code Playgroud)
我的样式表名为stylesheet.html,并且出于测试目的非常简单:
<style>
p {color: green;}
</style>
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它时,出现以下错误消息:ReferenceError:未定义“ include”。
在他们创建可重用函数include()的示例中,您需要将其添加到code.gs文件中:
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
Run Code Online (Sandbox Code Playgroud)
您总是可以像这样在HTML文件中直接使用打印脚本:
<html>
<head>
<base target="_top">
<?!= HtmlService.createHtmlOutputFromFile('stylesheet').getContent(); ?>
</head>
<body>
...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1651 次 |
| 最近记录: |