我是 Office 插件的新手,所以这可能是一个小错误。对于这个 Typescript React 插件,我创建了一个上下文菜单扩展点,单击时应该运行自定义函数 getButton(),目前它只是 console.logs 一个简单的字符串(“berry !”)。但是,单击后它并没有这样做,而是打开了一个小型开发人员窗口并显示命令 .html 文件的正文标签。当我右键单击该窗口并查看它的控制台时,我在那里看到我的函数打印测试字符串。我希望该开发人员窗口根本不打开,而是在任务窗格控制台内记录字符串。
我做错什么了?
清单文件
<FunctionFile resid="Commands.Url" />
<!-- other stuff -->
<ExtensionPoint xsi:type="ContextMenu">
<OfficeMenu id="ContextMenuText">
<Control xsi:type="Menu" id="TestMenu2">
<Label resid="residLabel" />
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16" />
<bt:Image size="32" resid="Icon.32x32" />
<bt:Image size="80" resid="Icon.80x80" />
</Icon>
<Items>
<Item id="showGallery2">
<Label resid="residLabel"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16" />
<bt:Image size="32" resid="Icon.32x32" />
<bt:Image size="80" resid="Icon.80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>getButton</FunctionName>
</Action>
</Item>
</Items>
</Control>
</OfficeMenu>
</ExtensionPoint>
<!-- other stuff -->
<bt:Urls>
<bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html" />
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html" />
</bt:Urls>
命令.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<!-- Office JavaScript API -->
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
<script>
Office.onReady( () => {
Office.actions.associate("getButton", getButton);
});
function getButton(event) {
console.log("berry !");
event.completed();
}
</script>
</head>
<body>
Commands HTML File body.
</body>
</html>