zoukankan      html  css  js  c++  java
  • Vue v-if v-show

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <div id="app">
            <h1>{{msg}}</h1>
            <p>--------------------</p>
            <div v-if="flag">true</div>
            <div v-else-if>false</div><!-- 根据条件变化会进行多次渲染,投机条件每次发生变化组件都会进行销毁和创建,并重新渲染 -->
            <p>--------------------</p>
            <div v-show="flag">true</div>
            <div v-show="!flag">false</div><!-- 只会进行一次初始化渲染,把所有条件的组件都渲染出来,再根据条件变化进行CSS显示和隐藏 -->
            <button @click="flag=!flag">btn</button>
    
        </div>
        <script src="js/vue.3.2.2.js"></script>
        <script>
            // 1、创建Vue的实例对象
            const app = Vue.createApp({
                data(){//定义数据
                    return {
                        msg:'你好!',
                        flag:false
                    }
                }
            }).mount('#app');
        </script>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en" xmlns="http://www.w3.org/1999/html">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <div id="app">
            <div v-if="loginType==='phone'">
                <label>手机: </label>
                <input type="text" placeholder="请输入手机号">
                </br>
                <label>密码:</label>
                <input type="password" placeholder="请输入密码">
            </div>
            <div v-else-if="loginType==='email'">
                <label>邮箱: </label>
                <input type="text" placeholder="请输入邮箱号">
                </br>
                <label>密码:</label>
                <input type="password" placeholder="请输入密码">
            </div>
            <p>---------------------------------------</p>
            <div v-show="loginType==='phone'">
                <label>手机: </label>
                <input type="text" placeholder="请输入手机号">
                </br>
                <label>密码:</label>
                <input type="password" placeholder="请输入密码">
            </div>
            <div v-show="loginType==='email'">
                <label>邮箱: </label>
                <input type="text" placeholder="请输入邮箱号">
                </br>
                <label>密码:</label>
                <input type="password" placeholder="请输入密码">
            </div>
            <button @click="change">btn</button>
        </div>
        <script src="js/vue.3.2.2.js"></script>
        <script>
            // 1、创建Vue的实例对象
            const app = Vue.createApp({
                data(){//定义数据
                    return {
                        msg:'你好!',
                        loginType: 'phone'
                    }
                },
                methods:{
                    change(){
                        this.loginType === 'phone' ? this.loginType='email':this.loginType='phone';
                        // this.loginType === 'email' ? this.loginType='phone':tis.loginType='email';
                    }
                }
            }).mount('#app');
        </script>
    </body>
    </html>
  • 相关阅读:
    机器学习入门-数值特征-连续数据离散化(进行分段标记处理) 1.hist(Dataframe格式直接画直方图)
    机器学习入门-数值特征-进行多项式变化(将特征投影到高维度上) 1.PolynomialFeatures(将数据变化为多项式特征)
    读取配置文件包含properties和xml文件
    开发常用辅助软件
    将Solr的数据存到Hdfs上
    ClassPathXmlApplicationContext和FileSystemXmlApplicationContext区别
    Codis连接异常问题处理
    Ganglia安装
    Spark sql读取数据库和ES数据进行处理代码
    linux清理缓存的命令
  • 原文地址:https://www.cnblogs.com/mingforyou/p/15153300.html
Copyright © 2011-2022 走看看