首页 > 其他分享 >elementUI 的 input无法输入bug解决

elementUI 的 input无法输入bug解决

时间:2024-09-26 14:12:06浏览次数:1  
标签:elementUI formData deep bug item input prop forceUpdate

1、出现bug的原因
        是因为数据层虽然改变了,但是并没有引起视图层的变化

2、解决方案

@input="forceUpdate($event)" //在input框上加输入事件

forceUpdate(e) {
this.$forceUpdate() 强制刷新
}

jeecg-boot框架前端写了个筛选组件:SearchBox.vue,测试人员发现输入框无法输入数据,经查是这个问题。

<template>   <div>     <el-form :inline="true" ref="searchForm" :model="formData" :label-width="labelWidth">       <el-row style="display: flex;flex-wrap: wrap;">         <template v-for="(item, index) in searchOptions">           <el-col :xs="12" :sm="8" :md="8" :lg="6" :xl="4">             <el-form-item :label="item.label" :prop="item.prop">               <!-- 输入框 -->               <template v-if="item.isInput && item.isInput == 1">                 <el-input style="width:100%;" :allowClear="true" placeholder="请输入" @input="forceUpdate($event)" v-model="formData[item.prop]" />               </template>               <!-- 选择框 -->               <template v-if="item.isSelect && item.isSelect == 1">                 <el-select style="width:100%;" :disabled="item.disabled" filterable :clearable="item.isClearable != '0' " v-model="formData[item.prop]" placeholder="请选择" @change="val => { handleChange(val, item) }">                   <el-option v-for="(el, i) in item.options" :key="i" :value="el.value" :label="el.name" />                 </el-select>               </template>               <!-- 树选择框 -->               <template v-if="item.isTreeSelect && item.isTreeSelect == 1">                 <a-tree-select :allowClear="true" style="width:100%;" :replaceFields="item.replaceFields" :disabled="item.disabled" v-model="formData[item.prop]" placeholder="请选择" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :tree-data="item.options" @change="val => { handleChange(val, item) }" />               </template>               <!-- 时间选择 -->               <template v-if="item.isDate && item.isDate == 1">                 <el-date-picker style="width:100%;" v-model="formData[item.prop]" :format="item.format" :value-format="item.valueFormat" :type="item.type" placeholder="请选择" />               </template>             </el-form-item>           </el-col>         </template>         <!-- 查询重置按钮 -->         <el-col :xs="12" :sm="8" :md="8" :lg="6" :xl="4" style="margin-left: auto;">           <el-form-item label="" prop="" style="display: flex;justify-content: flex-end;">             <div class="btn-group-s">               <el-button type="primary" icon="el-icon-search" @click="onSearch(true)">查询</el-button>               <el-button style="margin-left: 8px" @click="onSearch(false)">重置</el-button>               <el-button v-for="(btn, idx) in extendBtn" :key="idx" :type="btn.type || 'primary'" style="margin-left: 8px" @click="btnClick(btn)">{{ btn.label }}</el-button>             </div>           </el-form-item>         </el-col>       </el-row>     </el-form>   </div> </template> <script> export default {   props: {     searchOptions: { type: Array, default: () => [] },     extendBtn: { type: Array, default: () => [] },     labelWidth: { type: String, default: '160px' },   },   components: {},   data() {     return {       formData: {},     }   },   mounted() {},   computed: {},   methods: {     init() {       this.searchOptions.map((i) => {         if (i.defaultVal) {           this.formData[i.prop] = i.defaultVal         } else {           this.formData[i.prop] = undefined         }       })       this.$emit('onSearch', this.formData)     },     btnClick(btn) {       this.$emit(btn.clickFn)     },     forceUpdate(e) {       this.$forceUpdate()   //强制刷新     },     // 查询or重置     onSearch(flag) {       if (!flag) {         this.formData = {}         this.$refs.searchForm.resetFields()         this.searchOptions.map((i) => {           if (i.defaultVal) {             this.formData[i.prop] = i.defaultVal           } else {             this.formData[i.prop] = undefined           }         })         this.$forceUpdate()       }       this.$emit('onSearch', this.formData)     },     handleChange(value, obj) {       this.formData = { ...this.formData, [obj.prop]: value }       this.$emit('handleChange', value, obj)     },   }, } </script> <style lang="less" scoped> @import '~@assets/less/normal.less';
/deep/.el-form-item {   margin-bottom: 5px;   width: 100%; } /deep/.el-form-item--mini .el-form-item__content {   width: calc(100% - 140px); }
.btn-group-s {   height: 28px;   display: flex;   align-items: center;   display: flex;   justify-content: flex-end; } /deep/.ant-select-selection__rendered {   line-height: 28px; } /deep/.ant-select-selection--single {   height: 28px; } /deep/.ant-select {   font-size: 12px; } </style>



标签:elementUI,formData,deep,bug,item,input,prop,forceUpdate
From: https://www.cnblogs.com/snowhite/p/18433339

相关文章

  • 05 第六组(10个) sorted enumerate callable id len range open input
    第六组(10个)lenprintinputopen,文件rangepy2:v1=rang(10)#会生成列表[0....9]立即创建v1=xrang(10)#生成对象不会立即创建,只有使用循环时,进行创建,用一个进行创建一个,更节省内存py3:v1=rang(10)#会生成列表[0....9]#生成......
  • bugtrap.dll报错影响工作?从根源解决bugtrap.dll缺失难题,让你的电脑告别频繁报错
    当您在使用电脑时遇到“找不到bugtrap.dll”或“bugtrap.dll报错”的提示,这意味着您的计算机上缺少或损坏了一个重要的动态链接库文件。bugtrap.dll文件通常是某些应用程序或游戏运行所需的组件之一,缺失或损坏该文件会导致程序无法正常启动或运行。此外,这类错误可能会频繁出现,......
  • 《如 何 速 通 一 套 题》5.1bug fixed
    好吧,那天晚上才发现数据错了,只能咕一下了,现在咕完了前情提要:5.0D补幺梨\(1\lem\le10^8\),\(1\len\le10^7\),一看就不是背包。那么,以背包的形式出现,但是不是背包,还能是什么呢?同余最短路。只能是同余最短路。然后由于\(n\)太大了,所以不同的值的数量估计不会很多,最大......
  • el-input只能输入某某格式
    1.只能输入数字<el-inputv-model="rowForm.carriage"@input="value=>rowForm.carriage=Number(value.replace(/[^\d]/g,''))"/>2. 输入数字和小数点@input="rowForm.carriage=rowForm.carriage.replace(/[^\d......
  • GZY.Quartz.MUI(基于Quartz的UI可视化操作组件) 2.7.0发布 新增各项优化与BUG修复
    GZY.Quartz.MUI(基于Quartz的UI可视化操作组件)2.7.0发布新增各项优化与BUG修复 前言时隔大半年,终于抽出空来可以更新这个组件了(边缘化了,大概要被裁员了)2.7.0终于发布了~更新内容:1.添加API类任务的超时时间,可以通过全局配置也可以单个任务设置2.设置定时任务日......
  • 报表中按下上下左右按键input会像excel一样跳转聚焦
    上下左右按键input聚焦###html使用在需要聚焦的input后加下面内容@keydown.native="handleKeyDown($event,0,0)":ref="'0_0'"或者@keydown.native="handleKeyDown($event,index,0)":ref="`${index}_0`"###引入此方法h......
  • 《生化危机4重制版》黑屏进游戏慢,dinput8.dll缺失如何解决?
    针对《生化危机4重制版》中出现的黑屏、进游戏慢以及dinput8.dll文件缺失的问题,可以采取以下步骤进行解决:一、解决dinput8.dll缺失问题dinput8.dll是DirectX组件之一,用于处理输入设备如键盘、鼠标等。如果这个文件丢失或损坏,游戏可能无法正常启动。以下是几种解决方法:重新......
  • 《冰汽时代2》有声音没有画面,提示dinput8.dll缺失的操作方法
    《冰汽时代2》进不去游戏,有声音没有画面,并提示dinput8.dll缺失的问题,可以通过以下几种操作方法来解决:一、重新安装游戏由于dinput8.dll文件通常与游戏相关,特别是那些需要处理游戏手柄功能的游戏,因此尝试重新安装游戏可能是最直接的解决方法。卸载当前的游戏版本,并从官方渠道......
  • el-input type='index' 输入非负数或保留一位小数的数字
    /^(0|[1-9]\d*)$/匹配非负整数^表示字符串的开始。0:匹配单个零。[1-9]\d*:匹配以1到9开头的数字,后面可以跟任意数量的数字(包括零)。$表示字符串的结束。/[^0-9]/g匹配任何非数字字符^在方括号内表示取反,意味着匹配不在指定范围内的字符0-9表示所有数字字符(从0到9)g是一......
  • 宝塔搬家后打开网站为何出现:No input file specified.
    当你在使用宝塔面板搬家后出现“Noinputfilespecified.”的错误,这通常是由于PHP解析器找不到正确的入口文件导致的。这种情况可能与 .user.ini 文件有关,尤其是当你打包网站源码时包含了根目录下的 .user.ini 文件。解决方案1.检查 .user.ini 文件删除 .user.in......