Home > Web Front-end > JS Tutorial > body text

Method to obtain dom elements based on vue1 and vue2

亚连
Release: 2018-05-29 16:32:46
Original
1780 people have browsed it

Below I will share with you a method of obtaining dom elements based on vue1 and vue2. It has a good reference value and I hope it will be helpful to everyone.

vue1.*In version

Add el='dom' to the tag, and then add this.$els.dom in the code In this way, you get the page element

For example:

Hello

Make your good color appear in red: this.$els.my-box.style.color = 'red'

##vue2.*version

Add ref='dom' in the tag, and then add this.$refs.dom in the code to get the page element

For example:

Hello

Make the color of Hello appear red: this.$refs.myBox.style. color = 'red

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Detailed explanation of VUE Extension of ElTableColumn in element-ui

Detailed explanation of Vue custom dynamic component instance

Introduction to time-sharing functions for javascript performance optimization

The above is the detailed content of Method to obtain dom elements based on vue1 and vue2. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!