获取你的自己的 Vue 服务器
App.vue
main.js
 
<template>
  <div>
    <h2>Example $el Object</h2>
    <p>We are not able to use the $el object to change the background color of the root DIV tag when there are other tags on the root level. Open browser console to see the error generated.</p>
    <button v-on:click="changeColor">Click here</button>
  </div>
  <p>With this extra p-tag there are two tags on the root level.</p>
</template>

<script>
export default {
  methods: {
    changeColor() {
      this.$el.style.backgroundColor = 'lightgreen';
    }
  }
}
</script>

<style>
#app > div, #app > p {
  border: solid black 1px;
  padding: 10px;
}
</style>                  
import { createApp } from 'vue'

import App from './App.vue'

const app = createApp(App)
app.mount('#app')
                  
https://127.0.0.1:5173/