12 props 传的是数组处理

<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>
原文地址:https://www.cnblogs.com/xiaoliziaaa/p/13126434.html