vue-test -----ListDemo 列表渲染

<template>
<h3>数组</h3>
  <button @click="addnums">添加数据</button>
  <p v-for="(item,index) in nums" :key="index">{{item}}</p>
</template>

<script>
export default {
  name: "ListDemo",
  data(){
    return{
      nums:["li","jia","yao"]
    }
  },
  methods:{
    addnums(){
      //this.nums.push("lin")
      this.nums.concat("zhang")
      console.log(this.nums.concat("zhang"))
    }
  }
}
</script>

<style scoped>

</style>
posted @ 2023-11-07 22:51  会秃头的小白  阅读(7)  评论(0编辑  收藏  举报