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>
  • 相关阅读:
    Bootstrap中的Dropdown悬停触发
    git常用命令整理
    ThinkPHP-项目模块分组后自定义类库文件放去哪?
    项目开发中常用的PHP实用代码算法
    1049. Counting Ones (30)
    1059. Prime Factors (25)
    1050. String Subtraction (20)
    观察者模式
    策略模式
    JVM剖析
  • 原文地址:https://www.cnblogs.com/fwjlucifinil/p/13541531.html
Copyright © 2011-2022 走看看