我正在努力更改现有的加载项以实现 JavaScript 模块。但是随着我的函数文件的更改,我的清单中声明的
ExecuteFunction
操作不再起作用。
清单:
<Item id="credit/en-CA">
<Label resid="enCreditEnveloppeButtonLabel"/>
<Supertip>
<Title resid="enCreditEnveloppeSuperTipTitle"/>
<Description resid="paneSubjectSuperTipDescription"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="icon16"/>
<bt:Image size="32" resid="icon32"/>
<bt:Image size="80" resid="icon80"/>
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>addEnveloppe</FunctionName>
</Action>
</Item>
函数文件之前:
<script type="text/javascript">
function addEnveloppe(event){
console.log(event.id); //This is logged
}
</script>
函数文件后:
<script type="module">
function addEnveloppe(event){
console.log(event.id); //The function is never called
}
</script>
我找到了一些使用 React 和 Node 的解决方案,但我不想创建一个完整的其他项目并更改现有代码以与 React 一起使用。 这是例子
如何使带有 JavaScript 模块的函数文件工作?我也尝试过导出
addEnveloppe
函数,但它也不起作用。
您指向的示例是用于使用“yo office”命令生成项目的存储库。基本打字稿和 html 中的相同内容可以在 https://github.com/OfficeDev/Office-Addin-TaskPane 中看到,包括它的命令方面。