VUE 删除,接口,弹框,值的传递
(角色关联用户=0)点击删除,目前直接删除成功(正确应该先提示“你确定要删除该角色吗?”)
<button @click="deleteNode">删除</button> <div> <a href="javascript:;" @click="quxiao"></a> <a href="javascript:;" @click="handleOkDep"></a> </div>
定义
data() { return { events:[], datas:[], } } },
点击删除按钮的时候值传到vue的data中
methods: { deleteNode (event, data) { // console.log(data) if (data.children.length > 0) { this.showModalDep() this.events=this.getParentData(event.target) this.datas = data }, //点击确认的时候获取值 handleOkDep(){ let parentData = this.events //重新获取值 //console.log(parentData) if (parentData) { let index = parentData.indexOf(this.datas)//重新获取值 //console.log(index) if (index !== -1) { parentData.splice(index, 1) } } let dataObj = { id: this.datas.id, rem: Math.random() } // return deleteDepartment(dataObj, JSON.parse(getStore('loginInfo')).token).then(res => { if (res.statusCode == 20000000) { this.$message.success(res.reason,3) this.getDepartmentData() } else { this.$message.warning(res.reason,3) } }) }, 2000); }, }