Home > php教程 > PHP开发 > body text

Vue version of message board

高洛峰
Release: 2016-11-30 16:48:34
Original
1745 people have browsed it

Use vue to make a small example to consolidate learning.

<body>
<div id="box">
    <input type="text" v-model=&#39;command&#39; @keyup.enter=&#39;add&#39; />
    <div v-show=&#39;list.length==0&#39;>暂无留言</div>
    <ul>
        <li v-for="value in list"track-by=$index>{{value}}
            <a href="javascript:;" @click=&#39;rm($index)&#39;>删除</a>
        </li>
    </ul>
</div>
<script src="libs/vue.js"></script>
<script>
    new Vue({
        el:&#39;#box&#39;,
        data:{
            command:&#39;&#39;,
            list:[]    
        },
        methods:{
            add:function(ev){
                this.list.unshift(this.command)    
                this.command=&#39;&#39;;
            },
            rm:function(index){
                this.list.splice(index,1)    
            }
                               
        }
    })
</script>
</body>
Copy after login


Related labels:
vue
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template