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

王林
王林Original
2021-10-11 15:13:383718browse

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>
    methods: {
      chooseLabel(){
      document.getElementById("chooselabel").style.background="blue";
      },
    },

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!

Statement:
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