Get the App
SLTechnology News&Howtos  ›  Development  › 

How vue.js deletes dom nodes

Shulou Source: shulou.com Published: 2022-06-03 08:42:01 11月15日 Update

This article mainly introduces vue.js how to delete dom nodes, the article is very detailed, has a certain reference value, interested friends must read it!

Vue.js delete dom node method: 1, v-for loop dom node to ensure that each li has a delete button, and bind delete event; 2, delete dom node, such as [this.datahistory.splice (this.$refs.li [index], 1)].

The operating environment of this paper: windows10 system, vue.js 2.9, thinkpad T480 computer.

Vue deletes the current dom node in two steps:

Step 1: v-for loop dom node, ensure that each li has a delete button, and bind the delete event

{{item}} delete

Step 2: delete the dom node

DeleteFn () {this.datahistory.splice (this.$refs.li [index], 1) / Click to call the delete method to delete the subscript item index in the datahistory array, and the 1 after the comma represents the deletion of the current 1 item} above is all the content of the article "how to delete dom nodes by vue.js". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Nodes events content buttons methods articles guarantees loops subscript representatives values interests guys buddies arrays more environment computers knowledge systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux OPPO Reno Shulou Information Shulou Technology