当前位置:网站首页>单项数据流之子组件修改父组件的值
单项数据流之子组件修改父组件的值
2022-06-29 13:25:00 【YingUser】
一般情况下,父传子,在子组件中是不能够修改父组件的值的,修改就回报错,但是有时候有想修改,那么怎么办呢?经过我不写的努力,终于找到解决办法了、、、、
**** 父组件 ***
这是我的父组件传了一个布尔值,
<scrollToTop :isFirstPage="isFirstPage" />
data() {
return {
isFirstPage:false,
};
},
***子组件***
<template>
<div class="ScrollToTop_components" v-if="isFirstPage">
<img @click="scrollToTop" class="icon" src="../../../assets/images/Result_to_top_icon.png" alt />
</div>
<div class="topcontrol_first" title="返回顶部" @click="scrollToTop" v-else>
<div class="topcontrol_two">
<div class="topcontrol_last"></div>
</div>
</div>
</template>
// 接收
props: {
isFirstPage: {
type: Boolean,
default: true,
},
},
data: function () {
return { previewProps: "" }; //因为在子组件要修改他的值,所以呢,我就用一个变量保存起来,这样修改就不会报错啦
},
scroll() {
window.addEventListener("scroll", () => {
const scrollTop = document.getElementsByTagName("html")[0].scrollTop;
if (scrollTop > 0) {
this.previewProps = false;
} else {
this.previewProps = true;
}
});
},这里只是布尔值,至于其他数据行不行需要验证,到时候会补充,谢谢
边栏推荐
- 微信小程序:图片秒加水印制作生成
- 强大、优秀的文件管理软件评测:图片管理、书籍管理、文献管理
- Teach you how to install the latest version of mysql8.0 database on windows, nanny level teaching
- windows平台下的mysql启动等基本操作
- Five years after graduation, I asked all the leaders around me and summarized their learning methods
- Characteristics of human immaturity
- 嵌入式开发:硬件在环测试
- php-fpm 启动参数及重要配置详解
- Valueerror: only TF native optimizers are supported in Eagle mode
- C keyboard hook
猜你喜欢

中康控股开启招股:拟募资净额3.95亿港元,预计7月12日上市

高校女生穿旗袍答辩!网友:导师说论文要是和旗袍一样漂亮就好了

Investors fell off the altar: 0 sales in half a year, transferred to business and delivered takeout

Introduction to reverse commissioning -pe file section table and block 03/07

Cloud native (31) | kubernetes chapter kubernetes platform basic pre installed resources

【黑马早报】中公教育市值蒸发逾2000亿;新东方直播粉丝破2000万;HM关闭中国首店;万科郁亮称房地产已触底;微信上线“大爆炸”功能...

微信小程序:云开发表白墙微信小程序源码下载免服务器和域名支持流量主收益

灵感收集·创意写作软件评测:Flomo、Obsidian Memo、Napkin、FlowUs

##Mondo Rescue制作镜像文件(有利于镜像损坏恢复)

Leetcode question brushing: String 07 (repeated substring)
随机推荐
Dynamic feedback load balancing strategy based on Cluster
【毕业季·进击的技术er】1076万毕业生,史上最难就业季?卷又卷不过,躺又躺不平,敢问路在何方?
Koa2+better-sqlite3 to add, delete, change and query
goby如何导出扫描结果
Introduction to esp8266: three programming methods "suggestions collection"
Mondo rescue creates an image file (which is conducive to image damage recovery)
Hash hash game system development explanation technology -- hash game system development solution analysis
喜迎市科协“十大”•致敬科技工作者 | 卢毅:守护电网传输安全的探索者
Open source machine learning platform
I talked about exception handling for more than half an hour during the interview yesterday
动荡的中介生意,不安的租房人
[cloud resident co creation] break through the performance bottleneck of image recognition through rust language computing acceleration technology
Applet Wechat: un nouveau réseau exclusif de microgroupes de développement de Cloud
Wechat applet: install B artifact and P diagram, modify wechat traffic main applet source code, Download funny joke diagram, make server free domain name
mysql多表查询
php-fpm 启动参数及重要配置详解
微信小程序:云开发表白墙微信小程序源码下载免服务器和域名支持流量主收益
June training (day 29) - divide and rule
Stable currency risk profile: are usdt and usdc safe?
Detailed explanation of machine learning out of fold prediction | using out of fold prediction oof to evaluate the generalization performance of models and build integrated models