Vue2的常用指令1v-once

<html>
<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>
</head>
<body>
    <div id="app">
        <p v-once>原始值:{{msg}}</p>
        <p>后面的:{{msg}}</p>
        <input type="text" v-model="msg">
    </div>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            data () {
                return {
                    msg:'今天天气很好'
                }
            }
        })
    </script>
</body>
</html>

原始值不加v-once效果


原始值加上v-once的效果图

 
 


加上v-once的标签内容不受v-model影响

猜你喜欢

转载自blog.csdn.net/xfmuchengxue/article/details/80699595