vue3 watchEffect 监听子组件变化

父组件

<template>
  <div id="app">
    <el-button @click="clickGetChild">父组件修改id的值</el-button>
    <homeCom ref="refHomeCom" :id="id"></homeCom>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import homeCom from "./components/home.vue";
// 变量
const refHomeCom = ref(null);
let id = ref("1");
onMounted(() => {});
const clickGetChild = () => {
  id.value += "33";
};
</script>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

子组件

<template>
  <div class="child-style">
    <h3>watchEffect 监听变化</h3>
    &

相关推荐

  1. vue3 watchEffect 监听组件变化

    2024-02-11 01:00:01       35 阅读
  2. Vue3watchEffect的使用

    2024-02-11 01:00:01       12 阅读
  3. Vue 监听状态 watch 与监听状态 watchEffect

    2024-02-11 01:00:01       34 阅读
  4. react父组件props变化的时候组件怎么监听

    2024-02-11 01:00:01       39 阅读
  5. Vue3 /父组件相互调用

    2024-02-11 01:00:01       18 阅读
  6. Vue3.0-watch&&watchEffect函数

    2024-02-11 01:00:01       34 阅读
  7. vue3里的watch与 watchEffect

    2024-02-11 01:00:01       33 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-11 01:00:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-11 01:00:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-11 01:00:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-11 01:00:01       20 阅读

热门阅读

  1. C++学习笔记——typedef和using

    2024-02-11 01:00:01       29 阅读
  2. 【算法题】91. 解码方法

    2024-02-11 01:00:01       32 阅读
  3. 常见的Web框架

    2024-02-11 01:00:01       34 阅读
  4. 笔记——asp.net core 中的 REST

    2024-02-11 01:00:01       33 阅读
  5. Ubuntu防火墙设置

    2024-02-11 01:00:01       35 阅读
  6. 带你了解软件系统架构的演变详解

    2024-02-11 01:00:01       31 阅读
  7. 假期刷题打卡--Day28

    2024-02-11 01:00:01       31 阅读
  8. 推理还原的干货

    2024-02-11 01:00:01       31 阅读
  9. js的循环遍历

    2024-02-11 01:00:01       31 阅读
  10. C语言中的宏定义:从常量到高级技巧

    2024-02-11 01:00:01       28 阅读
  11. [c/c++] 关于虚函数表

    2024-02-11 01:00:01       38 阅读
  12. Linux命令-axel命令(多线程下载工具)

    2024-02-11 01:00:01       31 阅读