vue-test --------ref

<template>
 <div ref="contain">{{content}}</div>
  <button @click="getElemet">获取元素</button>
  <input type="text" ref="username">
</template>

<script>
export default {
  name: "RefDemo",
  data(){
    return{
      content:"内容"
    }
  },
  methods:{
    getElemet(){
      console.log(this.$refs.contain.innerHTML="改变")
      console.log(this.$refs.username.value)
    }
  }
}
</script>

<style scoped>

</style>
posted @ 2023-11-07 22:55  会秃头的小白  阅读(10)  评论(0编辑  收藏  举报