【问题标题】:Error Message: function doGet for Google App Script to HTML错误消息:Google App Script to HTML 的函数 doGet
【发布时间】:2021-07-11 20:48:17
【问题描述】:

我正在尝试从 google 脚本创建一个 html wep 应用程序。我首先收到一条关于 no doGet Function 的错误消息。现在我收到一个新错误....异常:没有找到名为 messages 的 HTML 文件。 (第 21 行,文件“代码”)

我可以举一个 doGet 函数应该是什么样子的例子,这样我就可以继续生活了。我读过的任何内容都没有显示如何使用它。应该在开头和结尾在中间。拜托,我能用简单的英语得到一些答案吗?

这是我使用的代码:

function getRelevantMessages()
{
  var threads = GmailApp.search("from:mike@lifewayhomes.net AND subject: Fwd: New submission 
from Find Me the Perfert Home",0,10);
  var messages=[];
  threads.forEach(function(thread)
              {
                messages.push(thread.getMessages()[0]);
              });
  return messages;
}


function getMessagesDisplay()
{
  var templ = HtmlService.createTemplateFromFile('messages');
  templ.messages = getRelevantMessages();
  return templ.evaluate();  
}
function doGet(e) {
  return HtmlService
    .createTemplateFromFile('messages.html')//This is html file we want to render
    .setTitle("messages");//We can set title from here
}




 

【问题讨论】:

    标签: google-apps-script


    【解决方案1】:

    试试

    function doGet(e) {
      return HtmlService
        .createTemplateFromFile('messages')//This is html file we want to render
        .setTitle("messages");//We can set title from here
    }
    

    【讨论】:

    • 我仍然得到这个:异常:没有找到名为 messages 的 HTML 文件。 (第 21 行,文件“代码”)
    • 通常标题不包含扩展名,但如果您将文件命名为“messages.html”,则会再次添加扩展名,使其现在为messages.html.html,因此请尝试将文件重命名为@987654323 @ 然后您会在编辑器中注意到它被命名为 messsages.html 但 HtmlService 通常希望使用不带扩展名的名称。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-13
    • 2019-03-29
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    • 1970-01-01
    • 2018-03-04
    相关资源
    最近更新 更多