美文网首页
v-cloak 解决VUE页面载入时样式慢界面丑问题

v-cloak 解决VUE页面载入时样式慢界面丑问题

作者: 天马行空_9f6e | 来源:发表于2021-04-01 18:42 被阅读0次

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>

    <style>

        [v-cloak]{

            display: none;

        }

    </style>

</head>

<body>

    <div id="app">

        <!-- v-cloak 解决页面载入时样式慢界面丑问题 -->

        <p v-cloak>++++++{{msg}}------</p>

        <!-- v-text默认可以解决样式慢界面丑问题,但是不能随心所欲拼接字符串,只能在msg里面拼接后直接显示 -->

        <h4 v-text="msg2">======</h4>

        <!-- v-html可以解析内容中包含的html标签 -->

        <h4 v-html="msg2"></h4>

        <!-- 可以用 v-bind:或者直接用:获取vue中的变量,同时也可以拼接字符串 -->

        <input type="button" v-bind:value="msg + '111222'" @click="show" />

        <!-- 用v-on:或者 @ 定义事件,要执行的方法写在vue的methods中 -->

        <input type="button" :value="msg2" v-on:click="show" />

    </div>

    <script src="../lib/vue.min.js"></script>

    <script>

        var vm=new Vue({

            el:'#app',

            data:{

                msg:'Hello world!',

                msg2:'<h1>hhhhhhhhhhhhhhhhhhhhhhhhhhhh</h1>'

            },

            methods:{

                show:function(){

                    alert('HELLO ALERT!');

                }

            }

        });    

    </script>

</body>

</html>

相关文章