html页面引入vue.js 渲染时使用v-for会晃一下

2023-11-09  本文已影响0人  吖_7c06
<!DOCTYPE html>
<html lang="zh">

    <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>vue 避免渲染闪烁</title>
        <style type="text/css">
            [v-clock] {
                display: none;
            }
        </style>
    </head>

    <body>
        <div id="app" v-clock>
            <div>
                {{ message }}
            </div>
        </div>
        <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
        <script type="text/javascript">
          Vue.directive('clock',{
                bind(el,binding,vnode){
                console.log(el);
                el.style.display = "block"
             }
           })
            new Vue({
                el: '#app',
                data: {
                    message: 99999
                }
            })
        </script>
    </body>

</html>
上一篇 下一篇

猜你喜欢

热点阅读