1.vue中ref操作dom节点

vue中操作Dom节点的方法

 

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

 页面效果:

vue中操作Dom节点的方法

 

相关文章:

  • 2021-06-24
  • 2021-11-14
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-05
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2021-10-21
相关资源
相似解决方案