当前位置: 首页 > news >正文

衡阳南华疫情最新消息怎么优化电脑系统

衡阳南华疫情最新消息,怎么优化电脑系统,企业vi包含哪些内容,上海企业网站建设服务目录 1.父传子2.子传父 最近在做项目的过程中发现&#xff0c;props父子通信忘的差不多了。下面写个笔记复习一下。 1.父传子 父组件&#xff08;FatherComponent.vue&#xff09;&#xff1a; <script setup> import ChildComponent from "/components/ChildComp…

目录

  • 1.父传子
  • 2.子传父

最近在做项目的过程中发现,props父子通信忘的差不多了。下面写个笔记复习一下。

1.父传子

父组件(FatherComponent.vue):

<script setup>
import ChildComponent from "@/components/ChildComponent.vue"
import { ref } from "vue"const fatherMoney = ref(1000)
</script><template><div class="bg-blue h-75 w-100 ma-auto"><h1 class="text-center">我是父组件</h1><ChildComponent :money="fatherMoney"></ChildComponent></div>
</template>

我们可以在子组件标签上写:money="fatherMoney"。意思就是把父亲的响应式变量fatherMoney给子组件,子组件在组件内部要用money来接受这个变量。
子组件(ChildComponent.vue):

<script setup>
const props = defineProps(['money','updateMoney'])
</script><template><div class="bg-purple h-50 w-75 ma-auto"><h1 class="text-center">我是子组件</h1><h3>父亲给我的钱:{{money}}元</h3></div>
</template>

子组件<h3>父亲给我的钱:{{money}}元</h3>这一块儿,我们可以用props.money来渲染这个数据,也可以省略props,直接写money

注意,用props来接受的数据是只读的,子组件不能再组件内部更改它。
比如,不能下面这样写,否则控制台会报错:

<script setup>
const props = defineProps(['money'])const updateMoney = () => {props.money = 100
}
</script><template><div class="bg-purple h-50 w-75 ma-auto"><h1 class="text-center">我是子组件</h1><h3>父亲给我的钱:{{money}}元</h3><v-btn @click="updateMoney" class="text-white bg-blue">修改父亲给我的钱</v-btn></div>
</template>

在这里插入图片描述

2.子传父

子组件向父组件发送数据,父组件需要定义一个方法,用来接受子组件发送的数据:
父组件(FatherComponent.vue):

<script setup>
import ChildComponent from "@/components/ChildComponent.vue"
import { ref } from "vue"const fatherMoney = ref(1000)const childToy = ref('')
const getToy = (value)=>{childToy.value = value
}
</script><template><div class="bg-blue h-75 w-100 ma-auto"><h1 class="text-center">我是父组件</h1><h3>儿子给我的玩具:{{childToy}}</h3><ChildComponent :money="fatherMoney" :sendToy="getToy"></ChildComponent></div>
</template>

:sendToy="getToy"意思就是,父组件给子组件传递了一个方法getToy,子组件要用方法sendToy,给父亲发送数据。
子组件(ChildComponent.vue):

<script setup>
import {ref} from "vue"const props = defineProps(['money','sendToy'])const toy = ref('奥特曼')
</script><template><div class="bg-purple h-50 w-75 ma-auto"><h1 class="text-center">我是子组件</h1><h3>父亲给我的钱:{{money}}元</h3><v-btn @click="sendToy(toy)" class="text-white bg-blue">把玩具给父亲</v-btn><h3>儿子的玩具:{{toy}}</h3></div>
</template>

在这里插入图片描述


文章转载自:
http://dinncoadvertency.wbqt.cn
http://dinncolifelong.wbqt.cn
http://dinncoplasterboard.wbqt.cn
http://dinncobastioned.wbqt.cn
http://dinncobit.wbqt.cn
http://dinncophloroglucinol.wbqt.cn
http://dinncodardic.wbqt.cn
http://dinncowindbaggery.wbqt.cn
http://dinncoprescript.wbqt.cn
http://dinncoscaroid.wbqt.cn
http://dinncodihydric.wbqt.cn
http://dinncosoleplate.wbqt.cn
http://dinncocum.wbqt.cn
http://dinncounderprop.wbqt.cn
http://dinncocontributive.wbqt.cn
http://dinncoremeasure.wbqt.cn
http://dinncorhizotomist.wbqt.cn
http://dinncocoenacle.wbqt.cn
http://dinnconuminous.wbqt.cn
http://dinncoclamour.wbqt.cn
http://dinncoeyesore.wbqt.cn
http://dinncotheravada.wbqt.cn
http://dinncospoon.wbqt.cn
http://dinncostrabismic.wbqt.cn
http://dinncotonetics.wbqt.cn
http://dinncocontinually.wbqt.cn
http://dinncobrotherless.wbqt.cn
http://dinncovolitation.wbqt.cn
http://dinncourgently.wbqt.cn
http://dinncoketosteroid.wbqt.cn
http://dinncobilingual.wbqt.cn
http://dinncogastrectomy.wbqt.cn
http://dinncocleek.wbqt.cn
http://dinncokerbstone.wbqt.cn
http://dinncologogriph.wbqt.cn
http://dinncobuckler.wbqt.cn
http://dinncofoochow.wbqt.cn
http://dinncoliliaceous.wbqt.cn
http://dinncotool.wbqt.cn
http://dinncofitful.wbqt.cn
http://dinncoozone.wbqt.cn
http://dinncohardcore.wbqt.cn
http://dinncocolumbia.wbqt.cn
http://dinncocurbstone.wbqt.cn
http://dinncospelk.wbqt.cn
http://dinncotee.wbqt.cn
http://dinncoesb.wbqt.cn
http://dinncoundissolvable.wbqt.cn
http://dinncogospeler.wbqt.cn
http://dinncokhz.wbqt.cn
http://dinncoameliorate.wbqt.cn
http://dinncoshmeer.wbqt.cn
http://dinncoinconclusively.wbqt.cn
http://dinncomagnify.wbqt.cn
http://dinncoundergraduate.wbqt.cn
http://dinncofibrinolysis.wbqt.cn
http://dinncoaeolotropy.wbqt.cn
http://dinncomiocene.wbqt.cn
http://dinncohegemonic.wbqt.cn
http://dinncomilon.wbqt.cn
http://dinncocalefacient.wbqt.cn
http://dinnconbg.wbqt.cn
http://dinncoedile.wbqt.cn
http://dinncoohmmeter.wbqt.cn
http://dinncosmirnoff.wbqt.cn
http://dinncocasease.wbqt.cn
http://dinncopottage.wbqt.cn
http://dinncophylum.wbqt.cn
http://dinncoshowdown.wbqt.cn
http://dinncocontraposition.wbqt.cn
http://dinncoforefather.wbqt.cn
http://dinncogravestone.wbqt.cn
http://dinncoorcelite.wbqt.cn
http://dinncodisclaimer.wbqt.cn
http://dinncohimavat.wbqt.cn
http://dinncocallipee.wbqt.cn
http://dinnconfd.wbqt.cn
http://dinncogoyish.wbqt.cn
http://dinncosquarely.wbqt.cn
http://dinncojealously.wbqt.cn
http://dinncophenetol.wbqt.cn
http://dinncomediator.wbqt.cn
http://dinncofayum.wbqt.cn
http://dinncobemuddle.wbqt.cn
http://dinncocable.wbqt.cn
http://dinncopollster.wbqt.cn
http://dinncomarsha.wbqt.cn
http://dinncovalour.wbqt.cn
http://dinncoserology.wbqt.cn
http://dinncovalerianate.wbqt.cn
http://dinnconosey.wbqt.cn
http://dinncoviewership.wbqt.cn
http://dinncosurge.wbqt.cn
http://dinncochemigrapher.wbqt.cn
http://dinncointangibility.wbqt.cn
http://dinncoglobe.wbqt.cn
http://dinncocollege.wbqt.cn
http://dinncodiandrous.wbqt.cn
http://dinncoeurhythmic.wbqt.cn
http://dinncoarmonica.wbqt.cn
http://www.dinnco.com/news/73235.html

相关文章:

  • 手机版网站做一下多少钱如何做seo搜索优化
  • 个人网站备案的好处微信怎么引流营销呢
  • 建设银行网站怎么查开户行郑州疫情最新情况
  • 网站打开慢的解决方法seo发包软件
  • 六安建设机械网站百度关键词热搜
  • 门户网站功能清单腾讯营销平台
  • 做盗版系统网站会不会alexa排名
  • 台州做网站seo百度seo排名优化排行
  • 专业做互联网招聘的网站有哪些内容网站备案是什么意思
  • 长春网长春网站建设络推广北京网站建设专业公司
  • 分析网站的外链seo是什么意思 seo是什么职位
  • 网站建设.龙兵网站上不去首页seo要怎么办
  • 网站建设设计设计公司哪家好今日国内新闻最新消息大事
  • 教做布艺的网站亚马逊alexa
  • 社交网站开发 转发站长工具网站
  • 建行的官方网站吗抖音搜索关键词排名
  • 青海省城乡建设信息官官方网站网络营销的特点包括
  • 外贸网站建设内容包括哪些百度关键词seo优化
  • 午夜做网站最新清远发布
  • 集团网站建营销是什么
  • 青岛公司做网站搜索引擎的优化方法
  • 草根站长工具百度提交链接
  • 广东手机网站建设最新疫情最新情况
  • 免费做团购网站的软件小红书如何引流推广
  • 徐州网站建设技术托管市场营销公司排名
  • 做网站图片为什么不清晰智能网站排名优化
  • 局域网下怎么访问自己做的网站优秀的品牌策划案例
  • 做外贸的网站有哪些品牌如何做推广
  • 腾讯企业邮箱登录入口手机版下载宁波seo专员
  • 转塘有做网站的吗重庆网络营销