zoukankan      html  css  js  c++  java
  • electron-消息对话框

    showMessageBox 相关属性

    它有太多的属性,这里我们也只挑一些常用的属性来讲解,如果你在工作中具体使用,可以先到官网查询相关的API后,再根据需求具体使用。

    • type :String类型,可以选,图标样式,有noneinfoerrorquestionwarning
    • title: String类型,弹出框的标题
    • messsage : String 类型,必选 message box 的内容,这个是必须要写的
    • buttons: 数组类型,在案例中我会详细的讲解,返回的是一个索引数值(下标)
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Hello Demo</title>
    </head>
    
    <body>
        <h1>Hello demo</h1>
        <button id="btn">打开子窗口</button>
        <a id="go_a" href="https://www.cnblogs.com/fwjlucifinil/p/13535393.html">luc</a>
        <div id="son_call"></div>
        <button id="upload">12312</button>
        <img id="img_xjj" style=" 100%;">
        <button id="xiaoxi">消息对话</button>
    </body>
    <script src="render/index.js"></script>
    <script>
        const {dialog} = require('electron').remote
        var xiaoxi_btn = document.getElementById('xiaoxi')
        xiaoxi_btn.onclick = function(){
            dialog.showMessageBox({
                type:'warning',
                title:'核警报',
                message:'是不是你!!',
                //点击后返回数组下标
                buttons:['yes','no']
            }).then(result=>{
                console.log(result)
                if(result.response == 0){
                    alert('哇哈哈哈哈哈哈哈哈哈!!!')
                }else if(result.response == 1){
                    alert('宾果')
                }
            })
        }
    </script>
  • 相关阅读:
    David Cutler NT之父
    VS2012 RC 编译Qt 4.8.2完整过程
    vm demo加固分析
    IDA dump so
    博客园首次发帖
    WebRTC本地选择codec(web本地模拟)
    Android 摄像头预览悬浮窗,可拖动,可显示在其他app上方
    [译] 清除浮动的新方法
    《学习HTML5游戏编程》译记
    Web中的Tip组件实现
  • 原文地址:https://www.cnblogs.com/fwjlucifinil/p/13541531.html
Copyright © 2011-2022 走看看