美文网首页
vue-html vue-text vue-once v

vue-html vue-text vue-once v

作者: 郭佳伟666 | 来源:发表于2018-09-24 15:13 被阅读0次
1.vue-html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
   <div id='app'>
       <input type="text" v-model='msg'>
       <p v-html='msg'>{{msg}}</p>
      
   </div>
    <script src='vue.js'></script>
    <script>
       new Vue({
           el:'#app',
           data:{
               msg:'hello'
           }
       })
    </script>
</body>
</html>
效果图示:
vue-html.png
2.vue-text
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
   <div id='app'>
       <input type="text" v-model='msg'>
     
       <h3 v-text='msg'>{{msg}}</h3>
    
   </div>
    <script src='vue.js'></script>
    <script>
       new Vue({
           el:'#app',
           data:{
               msg:'hello'
           }
       })
    </script>
</body>
</html>
效果图示:
vue-text.png
3.vue-once

vue-once只绑定一次

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
   <div id='app'>
       <a href="" v-once>{{msg}}</a>
   </div>
    <script src='vue.js'></script>
    <script>
       new Vue({
           el:'#app',
           data:{
               msg:'hello'
           }
       })
    </script>
</body>
</html>
效果图示:
vue-once.png
4.vue-pre

vue-pre原样输出

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
   <div id='app'>
       <h1 v-pre>{{msg}}</h1>
   </div>
    <script src='vue.js'></script>
    <script>
       new Vue({
           el:'#app',
           data:{
               msg:'hello'
           }
       })
    </script>
</body>
</html>
效果图示:
vue-pre.png
5.vue-cloak
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        [v-cloak]{
            display:none;
        }
    </style>
</head>
<body>
   <div id='app'>
       <h1 v-cloak>{{msg}}</h1>
   </div>
    <script src='vue.js'></script>
    <script>
       new Vue({
           el:'#app',
           data:{
               msg:'hello vue'
           },
           beforeMount:function(){
               alert('beforeMount')
           }
       })
    </script>
</body>
</html>
效果图示:
vue-cloak.png

点击确定后:


image.png

相关文章

网友评论

      本文标题:vue-html vue-text vue-once v

      本文链接:https://www.haomeiwen.com/subject/voacoftx.html