Office js:我可以使用 Visual Studio 在我的 Word 插件中使用 Web 组件吗?
Office js : can i use web component in my Word addin using Visual Studio?
我想在我的 Word 插件中使用 Web 组件,但我有一个简单测试出现的错误,错误如下:
无法获取未定义或空引用的 属性 'define'。
提前致谢!
Test.js
class MyProduct extends HTMLElement {
constructor() {
super();
this.innerHTML = "hello";
}
}
window.customElements.define('my-product', MyProduct); //The error is just here
Test.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>Word Add-In with Commands Sample</title>
<script type="module" src="Test.js"></script>
</head>
<body>
<my-product></my-product>
</body>
</html>
window.customElements.define('my-product', MyProduct);
// Unable to get property 'define' of undefined or null reference.
JavaScript API for Office与FireFox/Chromium/Safari浏览器APIs不同 =17=]
未定义的错误说:window
元素上没有 customElements
API。
(也没有 浏览器 window
)
要了解您可以在 Word 中使用 JavaScript 做什么,请参阅:https://docs.microsoft.com/en-us/javascript/api/word?view=word-js-preview
暂时; Office 加载项中没有自定义元素。
我想在我的 Word 插件中使用 Web 组件,但我有一个简单测试出现的错误,错误如下: 无法获取未定义或空引用的 属性 'define'。
提前致谢!
Test.js
class MyProduct extends HTMLElement {
constructor() {
super();
this.innerHTML = "hello";
}
}
window.customElements.define('my-product', MyProduct); //The error is just here
Test.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>Word Add-In with Commands Sample</title>
<script type="module" src="Test.js"></script>
</head>
<body>
<my-product></my-product>
</body>
</html>
window.customElements.define('my-product', MyProduct);
// Unable to get property 'define' of undefined or null reference.
JavaScript API for Office与FireFox/Chromium/Safari浏览器APIs不同 =17=]
未定义的错误说: 要了解您可以在 Word 中使用 JavaScript 做什么,请参阅:https://docs.microsoft.com/en-us/javascript/api/word?view=word-js-preview 暂时; Office 加载项中没有自定义元素。window
元素上没有 customElements
API。
(也没有 浏览器 window
)