Home >Web Front-end >Vue.js >How to dynamically modify the background color in vue.js
vue.js method to dynamically modify the background color: [methods: {chooseLabel(){document.getElementById("chooselabel").style.background="blue";},},].
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!