<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>
