0
点赞
收藏
分享

微信扫一扫

设计模式-简单工厂模式(静态工厂模式)java实现

小月亮06 2023-08-10 阅读 69
<template slot-scope="{row,$index}" slot="menu">
    <el-button v-if="row.editable" type="text" size="small" @click="changeStatus(row,$index)">编辑</el-button>
    <el-button v-else type="text" size="small" @click="changeStatus(row,$index)">保存</el-button>
</template>



import { cloneDeep } from "lodash";

changeStatus(row,index){
	let item = cloneDeep(this.dataList[index]);// let item = this.dataList[index];//注意直接 这么写不生效,地址内存空间不变
	item.editable = !row.editable
	this.$set(this.dataList,index,item)//注意这句不能省略
},

cloneDeep:在很多情况下,我们都需要给变量赋值,给内存地址赋予一个值,但是在赋值引用值类型的时候,只是共享一个内存区域,导致赋值的时候,还跟之前的值保持一致性。

举报

相关推荐

0 条评论