码迷,mamicode.com
首页 > 编程语言 > 详细

12 props 传的是数组处理

时间:2020-06-14 20:55:27      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:删除   eth   detail   upd   code   methods   filter   sage   required   

<template>
  <div>InfoDetailed</div>
</template>
<script>
export default {
  name: "InfoDetailed",
  props: {
    treeData: {
      type: Array,
      required: true
    }
  },
  data() {
    return {};
  },
  methods: {
    handleRemoveConfirm(row) {
      deleteCategory({ categoryId: row.id })
        .then(data => {
          this.$message.success(data.message);
          // 方法1:数组同基本数据类型看待,要显式通知(update)父组件sync
          // const res= this.treeData.filter(e => e.id !== row.id);
          // this.$emit("update:treeData", res);

          //方法2:实现删除数组里面特定的项,父组件的值同时被修改(不用通知父组件)
          let index = this.treeData.findIndex(e => e.id === row.id);
          this.treeData.splice(index, 1);
        })
        .catch(err => console.log(err));
    }
  }
};
</script>
<style lang="scss" scoped></style>

 

12 props 传的是数组处理

标签:删除   eth   detail   upd   code   methods   filter   sage   required   

原文地址:https://www.cnblogs.com/xiaoliziaaa/p/13126434.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!