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

vue3踩坑问题记录

//vue3+element-plus
//1、placeholder换行显示
const startTxt = ref('')
const contentText = ref<any>('')
startTxt.value = "请描述问题内容、例如:"
historyData.prompt.forEach((el:any)=>{contentText.value += `\n${el.question}`})
<ElInputv-model="question"@keyup.enter="handleSend"@keydown.native.enter.prevent="handleEnter"type="textarea":placeholder="startTxt+contentText":autosize="{ minRows: 6, maxRows: 6 }"resize="none"class="input-with-line-break"/>2、禁用回车事件的默认行为
@keydown.native.enter.prevent="handleEnter"const handleEnter = function(event:any){event.preventDefault();
}
3、按钮样式
<ElButtonstyle="position: absolute; right: 10px; bottom: 10px"type="primary"round:icon="Promotion"plain@click="handleSend"/>
4、聊天功能,一直让新内容处在最下面
给聊天区域绑定ref;
nextTick(()=>{scrollTop.value.scrollTop = scrollTop.value.scrollHeight})5、两个不相关的表格同时联动横向滚动// 表格滚动,两个表格都绑定ref
//滚动公共方法
const scrollFun = function (data: any, el: any) {const scrollLeft = data.target.scrollLeftnextTick(() => {el?.setScrollLeft(Number(scrollLeft))})
}
//第一个表格
const handleScroll = function (event: any) {scrollFun(event, bottomTableRef.value)
}
//第二个表格
const handleScrollBottom = function (event: any) {scrollFun(event, topTableRef.value)
}
// 待优化,尽量别绑定在window上
window?.addEventListener('scroll', handleScroll, true)
window?.addEventListener('scroll', handleScrollBottom, true)//离开做销毁,不然会引起内存泄漏
onUnmounted(() => {storageValue.value = ''window.removeEventListener('scroll', handleScroll)window.removeEventListener('scroll', handleScrollBottom)
})

http://www.lryc.cn/news/416295.html

相关文章:

  • Python 爬虫实战:Scrapy 框架详解与应用
  • 60 函数参数——关键参数
  • wps 最新 2019 专业版 下载安装教程,解锁全部功能,免费领取
  • 前端(三):Ajax
  • 启动 /使用/关闭 Redis 服务器
  • Linux系统中的高级SELinux安全策略定制技术
  • 使用 Ansible Blocks 进行错误处理
  • java中的静态变量和实例变量的区别
  • 【Effecutive C++】条款02 尽量以const, enum, inline替换 #define
  • leetcode-226. 翻转二叉树
  • 用的到linux-tomcat端口占用排查-Day5
  • mqtt协议详解(0)初步认识mqtt
  • Java语言程序设计基础篇_编程练习题*16.7 (设置时钟的时间)
  • YOLOv8新版本支持实时检测Transformer(RT-DETR)、SAM分割一切
  • 【传输层协议】UDP和TCP协议
  • Java Excel复杂表头,表头合并单元格
  • Java整合腾讯云发送短信实战Demo
  • 电路中电阻,电容和电感作用总结
  • OrangePi AIpro学习1 —— 烧写和ssh系统
  • Gather 全球化进程迅速 多重利好推动未来发展
  • 面试经典 222. 完全二叉树的节点个数
  • 【css】3d柱状图-vue组件版
  • 《计算机组成原理》(第3版)第3章 系统总线 复习笔记
  • 【网络安全】https协议的加密方案避免中间人攻击(MITM攻击)导致的数据泄露风险
  • 拼多多商家电话采集 拼多多店铺爬虫软件使用教程
  • RK3566 MIPI屏调试记录
  • 爬虫数据模拟真实设备请求头User-Agent生成(fake_useragent:一个超强的Python库)
  • 【教育宝-注册安全分析报告】
  • 3.达梦数据库基础运维管理
  • 【Linux】【系统纪元】Linux起源与环境安装