Vue variation example method Push message board

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
    <title id="title">{{title}}</title>
</head>
<body>
<div id="ask"><!- >ul<->VUE can not control the body and html tags
    
        <li v-for="v in list">
            {{v.content}}
        </li>
    </ul>

    <textarea v-model="content" cols="30" rows="10"></textarea>

    <button v-on:click="push">发表</button>
</div>
<script>
    var vue = function (options){new Vue(options)};
        a:
    vue ({' #Title ' , 
        Data: { 
            title: ' Message Vue variation example of the method Push ' 
        } 
    }); 
    var App = VUE ({ 
        EL: ' #ask ' , 
        Data: { 
            Content: '' , 
            List: [ 
                { ' Content ' : ' ask.mykeji.net ' }, 
                { ' Content ' : ' simple record ' }  
            ]
        },
        methods:{
            push(){
                var content_push = {'content':this.content};
                this.list.push(content_push);
                this.content='';
            }
        }
    });

</script>
</body>
</html>

 

Guess you like

Origin www.cnblogs.com/tommymarc/p/11627561.html