解决vue使用v-for渲染数据出现"DOMException: Failed to execute'removeChild' on 'Node': The node ....."

发布时间:

本文主要介绍 vue v-for渲染数据出现DOMException: Failed to execute ‘removeChild’ on ‘Node’: The node to be removed is not a child of this node.处理方案

data(){
	// 是否操作中 使用了vue的v-for渲染数组数据,在一次改变数组的时候出现异常报错,而实际的数组是已经变化过的了,页面卡死
			opting: true,
},
methods:{
	// 切换二级菜单栏
	changeSlider(index) {
		if (this.currentSlider != index) {
			this.opting = false
			setTimeout(()=>{
				this.opting = true
				//this.currentSlider = index
			},1)
			this.$forceUpdate()
		}
		
	},
}

解决vue使用v-for渲染数据出现

vue的DOM渲染的时候,删除之后DOM里面的还没有反应过来,在v-for的上一级添加一个v-if的状态,删除的时候隐藏,数组更新完成时候显示.