zoukankan      html  css  js  c++  java
  • Vue登录方式的切换

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>登录方式的切换</title>
        </head>
        <body>
            <div id="app">
                <template v-if="loginType==='email'">
                    <label>邮箱</label>
                    <input type="text" placeholder="请输入邮箱号" />
                </template>

                <template v-else-if="loginType==='phone'">
                    <label>手机号</label>
                    <input type="text" placeholder="请输入手机号" />
                </template>

                <button @click="btn">切换</button>
            </div>


            <script src="vue.js"></script>
            <script>
                new Vue({
                    el: "#app",
                    data: {
                        loginType: 'email'
                    },
                    methods: {
                        btn: function() {
                            console.log(this.loginType)
                            // 第一种方式
                            //this.loginType = (this.loginType === "email") ? 'phone' : 'email';

                            //第二方式
                            if (this.loginType == 'email') {
                                this.loginType = 'phone'
                            } else {
                                this.loginType = 'email'
                            }
                            return this.loginType;
                        }


                    }

                })
            </script>
        </body>
    </html>

  • 相关阅读:
    RATE-MAX——alpha冲刺总结随笔
    RATE-MAX alpha冲刺第十天
    RATE-MAX alpha冲刺第九天
    团队作业第六次——Daily6+1站立式会议+β冲刺汇总
    问题总结(事后诸葛亮和组员交换事宜)
    凡事预则立
    测试随笔
    冲刺随笔
    alpha冲刺——第十天
    alpha冲刺——第九天
  • 原文地址:https://www.cnblogs.com/wangshuang123/p/10777586.html
Copyright © 2011-2022 走看看