当前位置:网站首页>Resolve the conflict between computed attribute and input blur event
Resolve the conflict between computed attribute and input blur event
2022-04-23 14:40:00 【Feather_ seventy-four】
background : The search box is reused on the home page and search page , The search content of the home page needs to be transferred to the search page and displayed in the search box . The mode of transmission is through this.$router.push Add query Field .
<template>
<div class="index-container">
<a-input-search class="input-shape" v-model="searchInfo" placeholder="Search" @search="searchPaper(sendSearchInfo)" size="large" />
</div>
</template>
export default {
data() {
return {
sendSearchInfo: ''
};
},
methods: {
searchPaper(sendSearchInfo) {
this.$router.push({
path: '/search?',
query: {
info: sendSearchInfo
}
});
}
},
computed: {
searchInfo: {
get() {
return this.$route.query.info;
},
set(val) {
this.sendSearchInfo = val;
}
}
}
};
problem : stay input The data entered in will disappear when it loses focus
reason : When the page is initialized, it will execute get(), No longer perform , Every time you enter data, you execute set(). During the inspection, put the event in the listener blur Get rid of , That would not have happened . But printed onblur yes null, So it can't be removed . So it's the problem of data return .
resolvent :
export default {
data() {
return {
sendSearchInfo: ''
};
},
methods: {
searchPaper(sendSearchInfo) {
this.$router.push({
path: '/search?',
query: {
info: sendSearchInfo
}
});
}
},
computed: {
searchInfo: {
get() {
// because get involves this.sendSearchInfo, So every time set Will trigger get
if (this.sendSearchInfo != '') {
return this.sendSearchInfo;
} else {
return this.$route.query.info;
}
},
set(val) {
this.sendSearchInfo = val;
}
}
}
};
版权声明
本文为[Feather_ seventy-four]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231435193327.html
边栏推荐
- 555 timer + 74 series chip to build eight way responder, 30s countdown, proteus simulation, etc
- 8.2 文本预处理
- The initial C language framework is suitable for review and preliminary understanding
- Want to be an architect? Tamping the foundation is the most important
- Arduino for esp8266串口功能简介
- 1N5408-ASEMI整流二极管1N5408
- [servlet] detailed explanation of servlet (use + principle)
- 【Proteus仿真】自动量程(范围<10V)切换数字电压表
- QT actual combat: Yunxi calendar
- 单片机的函数信号发生器,输出4种波形,频率可调,原理图,仿真和C程序
猜你喜欢

do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、

AT89C52 MCU frequency meter (1Hz ~ 20MHz) design, LCD1602 display, including simulation, schematic diagram, PCB and code, etc

关于在vs中使用scanf不安全的问题
![Eight way responder system 51 Single Chip Microcomputer Design [with Proteus simulation, C program, schematic diagram, PCB files, component list and papers, etc.]](/img/1b/d1dea1726f3f91d2ba1ab8f2d7ff4c.jpg)
Eight way responder system 51 Single Chip Microcomputer Design [with Proteus simulation, C program, schematic diagram, PCB files, component list and papers, etc.]

详解TCP的三次握手

Mq-2 and DS18B20 fire temperature smoke alarm system design, 51 single chip microcomputer, with simulation, C code, schematic diagram, PCB, etc

ArrayList collection basic usage

想要成为架构师?夯实基础最重要

OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示

利用 MATLAB 编程实现最速下降法求解无约束最优化问题
随机推荐
三、梯度下降求解最小θ
四层和八层电梯控制系统Proteus仿真设计,51单片机,附仿真和Keil C代码
Qt实战:云曦日历篇
2-Go变量操作
The art of automation
QT interface optimization: double click effect
Sed learning for application
Branch statement of process control
【JZ46 把数字翻译成字符串】
【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
初识STL
do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
51单片机的花卉、农田自动浇水灌溉系统开发,Proteus仿真,原理图和C代码
面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
Some little records~
解决computed属性与input的blur事件冲突问题
Proteus simulation design of DC adjustable regulated power supply (with simulation + paper and other data)
A blog allows you to learn how to write markdown on vscode
8.3 语言模型与数据集
矩阵交换行列