javascript - SharePoint 的 Web 部件自定义,按钮 Onclick 功能在 typescript 中不起作用
问题描述
SharePoint 的 Web 部件自定义,按钮 Onclick 功能在 typescript 中不起作用。我们使用 NPM 和 typescript 自定义了 Web 部件。在打字稿中,当我们为该按钮分配函数调用时,onclick 事件不起作用。你能提供解决方案吗?
public openNewPage():void {
let site = this.context.pageContext.site.absoluteUrl;
console.log("Site: "+site);
const webPart: CreatePageWebPart = this;
window.onload= function (){
this.document.querySelector('#btnCopy').addEventListener('click', () => {
var headtext = document.getElementById("pageName");
alert(headtext);
});
}}
解决方案
推荐阅读
- angular - BreakpointObserver 没有触发
- django - Django对锚标签没有响应
- blockchain - Corda 数据库中的数据存储在哪里?
- c++ - C++ 2d 静态数组和内存分配
- android - 在片段之间快速切换时 Mapbox 崩溃
- typescript - 如何在打字稿中 navigator.geolocation.getCurrentPosition 的成功回调函数中传递额外的参数?
- android - 添加新记录后 Flutter FutureBuilder 不会重新加载
- javascript - 将数据从表传递到模态表单
- ocaml - ocamlc - 编译 ocaml-wasm - 错误:/usr/lib/ocaml/bigarray.cma 不是字节码目标文件
- ios - RxSwift : BehaviorRelay 代替变量使用