![](/img/trans.png)
[英]How to integrate Google Admob Ads in a MIT App Inventor 2 project?
[英]Google Script : multiple doPost in one project using MIT App inventor
有沒有一種方法可以讓我在 MIT 應用程序發明者屏幕上配置多個按鈕,以將不同的數據發布到谷歌表格。 據我了解,谷歌腳本中只能有一個 doPost() 方法。
所以如果我在應用程序上有不同的按鈕,我想在谷歌應用程序腳本中調用不同的 function 我不知道該使用什么。 我可以在 MIT 應用程序發明者中為不同的按鈕使用什么不同的標識符。
謝謝
您可以為此使用parameters
,方法是將按鈕設置為指向不同的 url,然后通過使用 doGet(e) 中的e.parameters
檢索用戶的選擇。
HTML代碼
在您的 HTML 模板中,您將構建鏈接/按鈕以使用您想要的任何參數調用您的應用程序,例如:
<!--The url comes from the template - see below-->
<a href="<?=url?>?functionOne=true">Function one</a>
<a href="<?=url?>?functionTwo=true">Function two</a>
腳本
function doGet(e){
var functionOne = e.parameter.functionOne;
var functionTwo = e.parameter.functionTwo;
//When functionOne is alled
if (functionOne =="true"){
//Do what you want here for function one
}
else if (functionTwo == "true"){
//Do what you want here for function two
}
else {
//This can be your base case here
}
模板中的 URL
在評估模板之前,您需要包含腳本 url
template.url = ScriptApp.getService().getUrl()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.