随笔 - 111  文章 - 0  评论 - 1  阅读 - 29655

Vue-----alert页面弹框的使用方法

  alert通常用于页面弹出对话框操作,常用于获取错误信息、提示信息、显示内容等,下面是alert的一些基本用法

1、弹出固定的文字

alert("请输入账号密码")

注:需要加入双引号将文字括起来否则弹框不生效

2、动态切换内容一:不加引号

alert(this.userName)

注:通过this调用需要显示的内容,不需要加入引号

3、动态调用内容二:加入引号

alert('userName:${this.userName} password:${this.password}')

注:通过${}的方式在引号中调用需要获取的内容

 

第三种方法小编之前试的时候没有获取到信息,路过的大佬可以指点一下,代码放下面了

 

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
    <div style="text-align: center;" id="Application">
    <button v-on:click="clickButton"  >点击</button>
    </div>
    <script>
        const App={
            
            data() {
                return {
                    username:'这是一条消息'
                }
            },
            methods: {
                clickButton(){
                    alert('消息内容:${this.username}')
                }
               
            },
        }
        Vue.createApp(App).mount("#Application")
    </script>
</body>
</html>
复制代码

 

posted on   昨夜小楼听风雨  阅读(4412)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示