Vue简单切换页面-初学者

<!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="./vue.js"></script>
    <style>
        body {
            width: 100%;
            height: 500px;
            background-color: aliceblue;
        }
        
        .root {
            width: 375px;
            height: 667px;
            margin: 0 auto;
            border: 2px solid #333;
        }
        
        .header {
            width: 100%;
            height: 100px;
            margin-top: 20px;
            border-bottom: 1px solid #e2cacabd;
            display: flex;
            justify-content: center;
        }
        
        header a {
            line-height: 50px;
            text-align: center;
            color: #333;
        }
        
        .main {
            padding: 10px;
            padding-top: 15px;
            width: 100%;
        }
        
        .main input {
            margin-top: 10px;
            height: 20px;
            width: 350px;
            margin: 0 auto;
            padding: 5px;
        }
        
        .footer {
            width: 100%;
        }
        
        button {
            background-color: #3131e4;
            color: aliceblue;
            border: none;
            height: 20px;
            width: 350px;
            margin: 0 auto;
            margin-top: 20px;
            display: block;
        }
        
        img {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <div class="root">


        <div class="header">
            <a href="" @click.prevent="seen1">账号登录</a>
            <a href="" @click.prevent="seen2">二维码登录</a>
        </div>
        <div class="q1" v-if="seen">
            <div class="main">
                <input type="text" v-model="username" placeholder="请输入手机号邮箱">
                <input type="password" v-model="password" placeholder="请输入密码">
            </div>
            <div class="footer">
                <button type="submit" @click="login">登录</button>
            </div>
        </div>
        <div class="q2" v-else>
            <img src="./image/c6cfd30cadfc1d6ab1a19a90fea5f3c.jpg" alt="">
        </div>
    </div>
    <script>
        new Vue({
            el: ".root",
            data: {
                seen: true,
                username: '',
                password: '',

            },
            methods: {
                seen1: function() {
                    this.seen = !this.seen;
                },
                seen2: function() {
                    this.seen = !this.seen;
                },
                login: function() {
                    console.log(this.username, this.password);
                    // 假设验证成功,跳转到首页

                }
            },
        })
    </script>
</body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值