Home > Web Front-end > Vue.js > How to dynamically modify the background color in vue.js

How to dynamically modify the background color in vue.js

王林
Release: 2021-10-11 15:13:38
Original
3729 people have browsed it

vue.js method to dynamically modify the background color: [methods: {chooseLabel(){document.getElementById("chooselabel").style.background="blue";},},].

How to dynamically modify the background color in vue.js

The operating environment of this article: windows10 system, vue.js 2.9, thinkpad t480 computer.

Use js in vue to dynamically modify the background color:

The specific code is as follows:

<li  id="chooselabel" @click="chooseLabel" >js来动态改背景颜色</li>
Copy after login
    methods: {
      chooseLabel(){
      document.getElementById("chooselabel").style.background="blue";
      },
    },
Copy after login

Recommended learning: php training

The above is the detailed content of How to dynamically modify the background color in vue.js. 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