[英]web add-in load issues on Outlook desktop only
I've got a problem where my add-in is running fine in Outlook Online, but won't run in Outlook desktop. 我遇到了一个问题,即我的加载项在Outlook Online中运行正常,但在Outlook桌面中无法运行。 The add-in is successfully activated from the manifest, but fails after load.
从清单成功激活了该加载项,但加载后失败。 This is a React + TypeScript project (testing using NodeJS + webpack in Webstorm).
这是一个React + TypeScript项目(在Webstorm中使用NodeJS + webpack进行测试)。
I've narrowed the problem to the usage of ANY require statement for importing a reference. 我已经将问题缩小为导入引用的ANY require语句的用法。 If I eliminate it, it runs fine and shows my test Office UI Fabric CompoundButton component.
如果我消除它,它可以正常运行并显示我的测试Office UI Fabric CompoundButton组件。 With the code, it spins and eventually shows a blank page.
使用代码,它旋转并最终显示空白页。 No script exceptions are thrown, and this is enabled in IE settings.
不会引发脚本异常,并且在IE设置中启用了此功能。
Why would this fail only on the desktop? 为什么这只会在台式机上失败?
To repro, use three files: 要进行复制,请使用三个文件:
//myapp.tsx import TestComponent from './components/TestComponent'; import * as $ from 'jquery'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { AppContainer } from 'react-hot-loader'; const render = (Component) => { ReactDOM.render( , document.getElementById('container') ); }; Office.initialize = function () { $(document).ready(function () { console.log('====myapp.tsx.Office.initialize(): entered'); render(TestComponent); }); }; if ((module as any).hot) { console.log('====index.tsx.module() foo'); (module as any).hot.accept('./components/App', () => { const NextApp = require('./components/App').default; render(NextApp); }); } //TestComponent.tsx import * as React from 'react'; import { CompoundButton } from 'office-ui-fabric-react/lib/Button'; //============ // BAD CODE! //import foo = require('../scripts/test.jsx'); //============ export default class TestComponent extends React.Component { render() { console.log('====TestComponent.render()'); //============ // BAD CODE! //foo.testFunction(); //============ return( Create account ); } } //test.jsx export function testFunction(){ console.log("test.jsx: testFunction"); }
Office 2013 and 2016 for Windows (desktop apps) use an embedded IE 11 browser for rendering. Windows的Office 2013和2016(桌面应用程序)使用嵌入式IE 11浏览器进行渲染。 IE 11 doesn't support a lot of the recent JS features you find in Edge, Chrome, and Firefox.
IE 11不支持您在Edge,Chrome和Firefox中发现的许多最新JS功能 。 As such, you either need to polyfill the functionality you need to provide alternative paths for IE 11.
因此,您要么需要填充功能,要么需要为IE 11提供替代路径。
One quick-fix may be just changing how TypeScript is generating JS so that it is compatible with IE 11: 一个快速修复程序可能只是更改TypeScript生成JS的方式,使其与IE 11兼容:
{
"compilerOptions": {
"skipLibCheck": true,
"lib": [ "es5", "dom", "es2015.promise" ]
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.