主组件

<template>
  <div>
   <uuu ref='test_hanshu'></uuu>   //ref 给子组件命名一个名字
   <p @click="clickme">点击我</p>
  </div>
</template>
<script>
import uuu from "../17/17-2copy"
export default {
  data() {
    return {
      visible: false,
    };
  },
  components: {
      uuu
    },

  methods: {
    clickme(){
       const a="我是超人";
      this.$refs.test_hanshu.lucax(a)   //调用子组件里面的方法
    }
   
    }
};
</script>

 后计: $refs 也可以拿子组件的 值 修改 

this.$refs.test_hanshu.值=123

子组件

<template>
  <div>
   我是17-2
  </div>
</template>
<script>
export default {
  data() {
    return {
      visible: false,
    };
  },
  methods: {
   lucax(uir){
     console.log(uir)
   }
    }
};
</script>

 

 

参考 https://www.cnblogs.com/ygyy/p/13396213.html

 

子组件 调用父组件的方法

https://blog.csdn.net/zgrkaka/article/details/100528714

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2021-11-07
  • 2021-08-23
  • 2022-01-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案