vue2 簡單的留言板


沒有寫樣式,只是寫個功能

<template>
<div class="headers">
  <div class="form">
    <input type="text" v-model="text"/>
    <button v-on:click="tabs">提交評論</button>
  </div>

 <div class="text">
   <div v-for="(name,index) in arr" v-on:click="dele(index)">{{name.text}}</div>   /* dele的index是下標,用來刪除我們點擊的信息 */
 </div>
</div>
</template>
<script>
export default {
data(){
  return {
   text:"",
   arr:[]
  }
},
 methods: {
    tabs:function(){
       this.arr.push({text:this.text});
       this.text="";
       console.log(this.arr)
    },
    dele:function(index){
      this.arr.splice(index,1)
     }
 }
};
</script>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM