google-apps-script - Google 表格插件侧边栏点击事件不适用于某些用户
问题描述
谷歌表格附加边栏问题
单击侧边栏中的菜单项时,不会触发 Code.gs 中的应用脚本功能。google.script.run.withSuccessHandler().withFailureHandler().generateContract();
---> 不适用于某些用户。
代码.gs
function onOpen() {
SpreadsheetApp.getUi().createAddonMenu().addItem('Sidebar',
'showSidebar').addToUi();
}
function generateContract() {
var ui = SpreadsheetApp.getUi();
ui.alert("Hello there! You're in the generateContract Function.");
return;
}
function showSidebar() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Data");
var ui = SpreadsheetApp.getUi();
var emailID = Session.getEffectiveUser().getEmail();
var html= HtmlService.createHtmlOutputFromFile('sidebar').setTitle("Sidebar");
ui.showSidebar(html);
}
警报“您好!您在 generateContract 函数中。” 某些用户不会被解雇。不知道为什么。
边栏.html
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;500;600;700&display=swap" rel="stylesheet">
<base target="_top">
<script>
function generatecontracts() {
document.getElementById("generate-contracts").classList.toggle("show");
}
function GenerateContract() {
google.script.run.withSuccessHandler().withFailureHandler().generateContract();
}
</script>
</head>
<body style="margin: 0px; overflow: hidden">
<div class="dropdown">
<div class="d-flex">
<button onclick=generatecontracts() class="dropbtn db-txt">
Generate Contracts
</button>
<button onclick=generatecontracts() class="arrow">▼</button>
</div>
<div class="dropdown-content" id="generate-contracts">
<button class="drop-btn" onClick='GenerateContract()'>Generate Contract</button>
</div>
</div>
</body>
</html>
解决方案
推荐阅读
- java - 相对布局以编程方式将视图添加到其他未正确对齐的视图下方
- php - 用回调替换字符串的正确方法
- node.js - 在 Node.js 中动态构建 Mongoose 聚合查询
- java - SQL - 连接/引用多个表的列
- batch-file - 如何在带有多个命令行的新窗口中打开 exe?
- php - PHP数组字母排序以匹配MySQL顺序
- sql - 在 Postgresql 中重现 Excel IF 语句
- javascript - 为什么这个用于更改 css id 的 Javascript 命令不起作用?
- taskwarrior - taskwarrior - 是否可以报告花费在任务上的时间?
- css - 居中文字和图片