【发布时间】:2020-11-13 00:13:41
【问题描述】:
我最近在构建插件时使用 google.script.run 遇到错误
Chrome 开发者控制台显示:“消息:”传输或处理过程中出现错误……此请求。错误代码 = 10,路径 = /wardeninit”,名称:“TransportError”,堆栈:“TransportError:传输过程中出现错误.../js/3535021228-warden_bin_i18n_warden.js:198:247)”
我看到了:Uncaught TypeError: a is not a function at hf....
这似乎是在 Google 这边。我可以联系谁来查看它?关于为什么会发生这种情况的任何其他想法?
这是造成此错误的代码。 示例代码:https://docs.google.com/spreadsheets/d/1hWifp75srJFHpnkCQx3YLxa3XB2gsKSmHNz3muYXK8U/edit#gid=0
function onInstall(e){
onOpen(e);
}
function onOpen(e){
var ui = SpreadsheetApp.getUi();
ui.createAddonMenu()
.addItem('Launch main menu', 'showSidebar').addToUi()
}
function showSidebar() {
var html = HtmlService.createTemplateFromFile('mainSidebar').evaluate()
.setTitle("Test")
.setWidth(300);
SpreadsheetApp.getUi()
.showSidebar(html);
}
function unittest(){
var documentProperties = PropertiesService.getDocumentProperties();
documentProperties.setProperty('firstRun', true);
}
function checkProperty(prop){
let documentProperties = PropertiesService.getDocumentProperties();
let property= documentProperties.getProperty(prop)
return property
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<style>
body { font-size: 16px;}
.button1 {
background-color: #2A8947; /* green */
border: none;
color: white;
padding: 15px 24px;
width:300px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
}
</style>
</head>
<body>
<div style="margin-bottom:12px" >
<h1>Main Menu</h1>
<ul class="collapsible">
<li>
<div class="collapsible-header button1">Menu</div>
<div class="collapsible-body"><span>Accordian</span></div>
<div class="collapsible-body"><button class="btn waves-effect waves-light green darken-2 white-text" id="setup" align="center">Setup<i class="material-icons right">settings</i></button></div>
</li>
</ul>
</div>
<hr>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script>
$(document).ready(function(){
$('.collapsible').collapsible();
google.script.run.withSuccessHandler('testRun').withFailureHandler('fail').checkProperty('firstRun')
});
function testRun(run){
console.log('run',run)
}
function fail(e){
console.log('fail',e)
}
</script>
</body>
</html>
【问题讨论】:
-
请提供一组重现步骤来重现此行为。我想我们应该
Test as add-on...并打开侧边栏?然后怎样呢?应该采取什么行动?预期的行为是什么?请考虑提供minimal, reproducible example。此外,如果您认为这是一个错误,您可以在问题跟踪器中的this component 报告它。
标签: google-apps-script google-sheets