我正在try 在我的Angular项目中实现Dynamsoft Web Twain.但安装弹出窗口中没有关闭按钮.如何在弹出窗口中添加关闭按钮?

我的Angular 版本是13.3

推荐答案

有三种方法可以在dynamsoft.webtwain.install.js中添加关闭按钮:

  • _this.DWT.ShowMessage(ObjString.join(''), { width: promptDlgWidth, headerStyle: 1, closeButton: true });中的值closeButton更改为true.默认值为false.

  • 根据当前代码添加按钮元素.

    例如,添加

    ObjString.push('<div><a id="dwt-btn-close" 
    onclick="Dynamsoft.onClose()"><div class="dynamsoft-dwt-dlg- 
    button">Close</div></a></div>');
    

    在下面

    ObjString.push(' onclick="Dynamsoft.DCP_DWT_onclickInstallButton()"> 
    <div class="dynamsoft-dwt-dlg-button">Download</div></a></div>');
    

    然后添加按钮点击功能

    Dynamsoft.onClose = function() {
      document.getElementsByClassName('dynamsoft-dialog') 
    [0].style.display = 'none';
    }
    

    在上面

    Dynamsoft.DCP_DWT_onclickInstallButton = function ()
    

    现在,弹出窗口如下所示:

    enter image description here

    可以单击"关闭"按钮关闭对话框.由于为z-index,弹出对话框下的HTML元素不可 Select .一个棘手的方法是在隐藏弹出对话框后修改z-index:

    let divs = document.getElementsByTagName('div');
      for (let i = 0; i < divs.length; i++) {
        divs[i].style.zIndex = -1;
      }
    
  • 不要打_this.DWT.ShowMessage(ObjString.join(''), { width: promptDlgWidth, headerStyle: 1, closeButton: true });.相反,可以使用jQuery创建自定义对话框.例如:

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>jQuery UI Dialog - Default functionality</title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
    <script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"> 
    </script>
    <script>
    $( function() {
      $( "#dialog" ).dialog();
    } );
    </script>
    </head>
    <body>
    <div id="dialog" title="Basic dialog">
    <p>This is the default dialog which is useful for displaying 
    information. The dialog window can be moved, resized and closed with 
    the &apos;x&apos; icon.</p>
    </div>
    </body>
    </html>
    

Angular相关问答推荐

PrimeNG面包屑组件生成奇怪的&

当项目具有BrowserAnimationsModule时,Angular UI未拾取数据模型更改

Angular KendoGrid RowReorderable,drop不适用于新添加的行

当嵌套在异步容器中时,S会阻止具有动态值的ionic 段工作吗?

如何从URL中角下载图片?

使用BLOB数据类型时,HTTPCLIENT中可能存在错误

如何以Angular 解析表单控件名称的无值访问器?

从 applescript 调用Angular 前端以从列表中 Select 一个项目

NgRx Effects 抛出类型错误,我不知道发生了什么

如何在独立组件中导入Angular innerHTML

大型 Angular 12 应用程序 - 我如何管理 js 文件

Angular:组件的内容投影访问数据

在 Angular material 表单元格中渲染 html

尽管模型中的变量发生了变化,但Angular 视图没有更新

如何从表单组中禁用的表单控件中获取值?

在 Ionic 2 中使用图像资源的正确方法

Angular2 ngFor跳过第一个索引

unexpected token < 错误

RxJS - 发生错误时观察到的不会完成

IE11中的Angular4应用程序运行问题