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

组件A底部栏(position: fixed )事件使用$emit更新内容失败bug解决

今天遇到一个很离奇的bug,记录一下

问题:在组件内底部栏使用$emit触发按钮事件但打印出来的值是初始化的值,更新的值被重置导致更新失败
原因:组件内底部使用了 position: fixed; 固定, 导致组件内插槽 this 与 保存按钮的this 不一致
解决: 取消position: fixed; 改用 position: absolute;

组件 editDetail

<div class="container">
  <div >
    ...
    <div class="footer">
       <el-button class="btn" size="mini" @click="submit">保存</el-button>
    </div>
  </div>
</div>
// 保存
submit() {
  this.$emit('submit')
},
.footer{
  // position: fixed;
  position: absolute;
  bottom: 0;
  min-height: 55px;
  background: #FFFFFF;
  z-index: 999;
  ...
}

页面 edit.vue

<editDetail  @submit="handleSubmit">
    <template slot="scope">
    	<el-form ref="form" :model="form" :rules="rules" :label-width="80px">
    	 	<el-form-item label="xxx" prop="xxx">
               ...
            </el-form-item>
            ...
		</el-form>            
    </template>
</editDetail>
 handleSubmit() {
 	console.log('form', this.form)
 }

http://www.kler.cn/a/416329.html

相关文章:

  • 【数据湖仓】-- 阿里云 dataworks 和 AWS Glue 数据治理工具对比
  • 虚拟机ubuntu-20.04.6-live-server搭建OpenStack:Victoria(五:OpenStack环境准备-compute node)
  • C++设计模式(模板模式)
  • AOA定位算法,平面上的angle of arrive定位算法与MATLAB实现
  • 【c++篇】:解读Set和Map的封装原理--编程中的数据结构优化秘籍
  • “岗位复合化、技能层次化” 高职大数据技术专业人才培养实践
  • MySQL8.0 双密码机制:解决应用程序用户不停机修改密码问题
  • AWS账号提额
  • 11.26 深度学习-初始化
  • C语言学习 13(编程题)
  • vue element-ui的el-image 和 el-table冲突层级冲突问题问题preview-teleported
  • 使用LLaMA-Factory微调时的数据集选择
  • SRIO DRP动态速率配置说明(详细讲解)
  • 环形链表系列导学
  • Spring Boot开发——整合JPA配置多数据源
  • 华纳云:怎么通过宝塔面板访问php My Admin?
  • 群控系统服务端开发模式-应用开发-前端邮箱配置开发
  • txt地图格式处理
  • 搜索二维矩阵 II(java)
  • Maven Surefire 插件简介