1.vue dom node operation in ref
<template> <div id="app"> <div ref="box">1111111111111111</div> <button @click="changeColor">改变</button> </div> </template> <script> export default { name: "app", data() { return { }; }, methods:{ changeColor() { this.$refs.box.style.color = 'red' } } }; </script> <style> </style>
Results page: