1.事件
2.取元素
3.函数
---------------------- 仔细看 有你想要的!

<template>
    <!-- $event是获取当前元素属性 -->
    <!-- ref相当于id -->
    <el-button ref='btn1'  @click="getname($event)">你好,我是黄晓明</el-button>
</template>
<script>
export default {
  name: "flowDetail",
  data() {
    return {
        stuname:'我是朱晓明'
    };
  },
  components: {
    
  },
  methods: {
      getname(val){
          //console.log(val.target.innerText )
          var name = this.stuname;
          this.stuname = this.$refs.btn1.$el.innerText;
          //this.$refs.btn1是取上面id为btn1的元素(说id是不严谨的)
          this.$refs.btn1.$el.innerText = name
      }
  },
  created() {
   
  },
  mounted() {
      
  }
};
</script>
Logo

前往低代码交流专区

更多推荐