惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 雪莉06

antd vue 树形表格 vue2 jeecgBoot keepalive 解决方案 vue中实现页面全屏和指定元素全屏 screenfull全屏组件的基本使用 网页导出EXCEL格式数据,长数字变为科学计数法的解决方法 dedecms织梦自定义表单导出到excel的方法 织梦dede:arclist按最新修改排序orderby=pubdate无效的解决方法 vue-router报错:Uncaught (in promise) NavigationDuplicated {_name: ‘NavigationDuplicated‘, name: ‘Navig nvm的安装和使用(转) vue数字翻牌效果 j-modal的 slot="footer" 失效 v-if判断页脚按钮 帝国CMS后台登录空白怎么办?如何修改成https ES6两个数组进行比较 element ui form表单 表格下嵌套动态表格,新增行,删除行 vue 父子组件传值报错:this.$emit is not a function 解决 dede列表页调用二三级导航栏(转载) a-table 鼠标滑过显示小手,当前行可点击(转载) echarts折线图使用dataZoom,切换数据时渲染异常,出现竖线bug vue里面修改title样式
elementUI 的 input无法输入bug解决
雪莉06 · 2024-09-26 · via 博客园 - 雪莉06

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>