厦门市规划建设局网站/流量宝官网

厦门市规划建设局网站,流量宝官网,网站后台管理系统的重要技术指标,wordpress跳转移动端模板需求&#xff1a;根据数据中的html&#xff0c;因为我是在做填空&#xff0c;所以是需要将html中的_____替换成input&#xff0c;由于具体需求我使用的是元素contenteditable代替的可编辑的input html部分 <div class"wrap"><component :is"rendered…

需求:根据数据中的html,因为我是在做填空,所以是需要将html中的_____替换成input,由于具体需求我使用的是元素contenteditable代替的可编辑的input

html部分

<div class="wrap"><component :is="renderedContent" ref="wrap_component" /></div>

js部分

// 这个是为了保证输入的时候光标保持在最后
const moveCursorToEnd = (element: HTMLElement) => {const range = document.createRange();const selection = window.getSelection();// 找到最后一个文本节点let lastTextNode: Text | any = null;const traverseNodes = (node: Node) => {if (node.nodeType === Node.TEXT_NODE) {lastTextNode = node as Text;}for (let i = 0; i < node.childNodes.length; i++) {traverseNodes(node.childNodes[i]);}};traverseNodes(element);if (lastTextNode) {range.setStart(lastTextNode, lastTextNode.textContent?.length || 0);range.collapse(true);if (selection) {selection.removeAllRanges();selection.addRange(range);}} else {range.setStart(element, 0);range.collapse(true);if (selection) {selection.removeAllRanges();selection.addRange(range);}}// 兼容性处理:确保元素获取焦点element.focus();if (document.activeElement !== element) {element.focus();}
};// 计算属性,用于生成渲染内容
const renderedContent = computed(() => {if (!itemConf.value.customConf?.inputHtml) return null;const parts = itemConf.value.customConf.inputHtml.split(/_{1,}/);let nodes: any = [];parts.forEach((part, index) => {if (part) {const replacedSpaces = part.replace(/ /g, '&nbsp;');const replacedPart = replacedSpaces.replace(/<div>/g, '<br>').replace(/<\/div>/g, '');nodes.push(h('span', { class: 'custom-span', innerHTML: replacedPart }));}if (index < parts.length - 1) {if (!inputValues.value[index]) {inputValues.value[index] = '';}if (!isInputFocused.value[index]) {isInputFocused.value[index] = false;}if (!isClearIconClicked.value[index]) {isClearIconClicked.value[index] = false;}if (!clearIconHideTimer.value[index]) {clearIconHideTimer.value[index] = 0;}const clearIcon = h(ElIcon,{class: ['clear_icon',{'is-hidden':inputValues.value[index].length === 0 ||itemConf.value.baseConf.isReadOnly ||!isInputFocused.value[index],},],onClick: () => {if (!itemConf.value.baseConf.isReadOnly) {isClearIconClicked.value[index] = true;inputValues.value[index] = '';if (inputRefs.value[index]) {inputRefs.value[index].innerText = '';}adjustInputWidth(index);handleChange(itemConf.value.customConf.inputGroup[index], '');// 点击后清除隐藏定时器clearTimeout(clearIconHideTimer.value[index]);}},},{ default: () => h(CircleClose) },);const inputNode = h('p',{contenteditable: !itemConf.value.baseConf.isReadOnly,class: ['underline_input',{'is-disabled': itemConf.value.baseConf.isReadOnly,},],disabled: itemConf.value.baseConf.isReadOnly,innerHTML: inputValues.value[index],placeholder: unref(itemConf).customConf?.inputGroup[index]?.placeholder || '请输入',onInput: async (event: InputEvent) => {const target = event.target as HTMLParagraphElement;adjustInputWidth(index);inputValues.value[index] = target.innerHTML;await nextTick(() => {moveCursorToEnd(target);});},onFocus: () => {if (!itemConf.value.baseConf.isReadOnly) {isInputFocused.value[index] = true;clearTimeout(clearIconHideTimer.value[index]);}},onBlur: () => {if (!itemConf.value.baseConf.isReadOnly) {handleChange(itemConf.value.customConf.inputGroup[index], inputValues.value[index]);clearIconHideTimer.value[index] = setTimeout(() => {if (!isClearIconClicked.value[index]) {isInputFocused.value[index] = false;}isClearIconClicked.value[index] = false;}, 200);}},onMousedown: (event: MouseEvent) => {if (itemConf.value.baseConf.isReadOnly) {event.preventDefault();event.stopPropagation();}},onKeydown: (event: KeyboardEvent) => {if (itemConf.value.baseConf.isReadOnly) {event.preventDefault();event.stopPropagation();}},ref: (el) => (inputRefs.value[index] = el),},// [clearIcon],);nodes.push(h('p', { class: 'underline_input_wrap' }, [inputNode, clearIcon]));}});return h('div', nodes);
});

css部分


.underline_input_wrap {display: inline-block;// max-width: calc(100% - 70px);position: relative;margin-top: 20px;margin-bottom: 0;max-width: calc(100% - 50px);
}
.underline_input {position: relative;height: 40px;min-width: 101px;// max-width: calc(100% - 70px);max-width: 100%;background: #f5f7fb;border-radius: 6px 6px 6px 6px;border: none;margin-left: 10px;margin-top: 0;margin-bottom: 0;display: inline-block;box-sizing: border-box;padding: 0 26px 0 12px;background: #f5f7fb;vertical-align: middle;color: #606266;background: #f5f7fb;vertical-align: middle;&:focus {outline: none;border: 1px solid #1a77ff;color: #606266;}&:disabled {color: #bbbfc4;cursor: not-allowed;}&::placeholder {color: #a8abb2;font-size: 14px;}
}.underline_input.is-disabled {color: #bbbfc4;cursor: not-allowed;
}.underline_input[contenteditable='true']:empty::before,
.underline_input.is-disabled:empty::before {content: attr(placeholder);color: #bbbfc4;
}
:deep(.clear_icon) {position: absolute;width: 14px;height: 14px;right: 5px;top: 50%;transform: translateY(-50%);cursor: pointer;color: #999;z-index: 10; /* 增加 z-index 确保在最上层 */&:hover {color: #666;}&.is-hidden {display: none;}
}

我们要模拟input可清除,所以需要我们去调整样式,以及placeholder样式问题

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/73959.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【AI】AI编程助手:Cursor、Codeium、GitHub Copilot、Roo Cline、Tabnine

文章目录 一、基本特性对比二、收费标准三、私有部署能力1、Tabnine2、Roo Code 三、代码补全与自然语言生成代码四、安装独立的IDE安装插件安装 五、基本使用&#xff08;一&#xff09;Cursor&#xff08;二&#xff09;GitHub Copilot1、获取代码建议2.聊天1&#xff09;上下…

三轴云台之角速度信号篇

三轴云台的角速度信号主要通过其内置的传感器&#xff08;如陀螺仪&#xff09;来感知和测量。 一、角速度信号的感知与测量 在三轴云台中&#xff0c;陀螺仪是测量角速度的关键组件。它通常安装在三个互相垂直的轴上&#xff08;通常为X、Y、Z轴&#xff09;&#xff0c;能够…

绿盟春招实习一面

《网安面试指南》https://mp.weixin.qq.com/s/RIVYDmxI9g_TgGrpbdDKtA?token1860256701&langzh_CN 5000篇网安资料库https://mp.weixin.qq.com/s?__bizMzkwNjY1Mzc0Nw&mid2247486065&idx2&snb30ade8200e842743339d428f414475e&chksmc0e4732df793fa3bf39…

进制转换(R转十)(1290. 二进制转换十进制、1292. 十六进制转十进制、1291. 八进制转十进制、1405. 小丽找潜在的素数)

题单地址&#xff1a;题单中心-东方博宜OJ 这里以二进制转十进制为例&#xff08;按位加权求和法&#xff09; 1290. 二进制转换十进制 问题描述 请将一个 25 位以内的 2 进制正整数转换为 1010 进制&#xff01; 输入 一个 25 位以内的二进制正整数。 输出 该数对应的…

9.嗅探与Wireshark进阶分析

嗅探与Wireshark进阶分析 第一部分&#xff1a;嗅探的概念与重要性第二部分&#xff1a;Wireshark进阶功能第三部分&#xff1a;嗅探实践与分析总结 目标&#xff1a; • 理解嗅探&#xff08;Sniffing&#xff09;的概念及其在网络安全中的作用 • 掌握Wireshark的进阶功能&a…

【Linux篇】进程控制

&#x1f4cc; 个人主页&#xff1a; 孙同学_ &#x1f527; 文章专栏&#xff1a;Liunx &#x1f4a1; 关注我&#xff0c;分享经验&#xff0c;助你少走弯路&#xff01; 1. 进程创建 1.1 fork函数 在linux中fork函数是非常重要的函数&#xff0c;它从已存在进程中创建一个…

HyperAD:学习弱监督音视频暴力检测在双曲空间中的方法

文章目录 速览摘要1. 引言2. 相关工作弱监督暴力检测双曲空间中的神经网络 3. 预备知识双曲几何切空间&#xff08;Tangent Space&#xff09;指数映射与对数映射&#xff08;Exponential and Logarithmic Maps&#xff09;3.1 双曲图卷积网络&#xff08;Hyperbolic Graph Con…

动态规划(6.不同路径II)

题目链接&#xff1a;63. 不同路径 II - 力扣&#xff08;LeetCode&#xff09; 解法&#xff1a; 本题为不同路径的变型&#xff0c;只不过有些地方有「障碍物」&#xff0c;只要在「状态转移」上稍加修改就可解决。 状态表示&#xff1a; 对于这种Γ路径类」的问题&#xf…

深度洞察:DeepSeek 驱动金融行业智能化转型变革

该文章为软件测评&#xff0c;不是广告&#xff01;&#xff01;&#xff01;&#xff01; 目录 一.金融行业的智能化转型浪潮​ 二.DeepSeek的核心技术剖析 1.DeepSeek 模型的金融智慧​ 2.实时联网搜索&#xff1a;把握金融市场脉搏​ 3.RAG 能力&#xff1a;铸就精准金…

蓝桥杯备考----》暴力枚举---金盏花

这道题&#xff0c;一共12位&#xff0c;给了后六位&#xff0c;我们只要枚举前六位就行了&#xff0c;当然如果是10的12次方的话&#xff0c;必须要开long long才可以存下&#xff0c;这点我们不要忘了 然后题目中又告诉了没有前导0&#xff0c;我们可以从100000开始枚举&…

RAG各类方法python源码解读与实践:利用Jupyter对RAG技术综合评测【3万字长文】

检索增强生成&#xff08;RAG &#xff09;是一种结合信息检索与生成模型的混合方法。它通过引入外部知识来提升语言模型的性能&#xff0c;从而提高回答的准确性和事实正确性。为了简单易学&#xff0c;不使用LangChain框架或FAISS向量数据库&#xff0c;而是利用Jupyter Note…

Python列表2

print("—————————— 列表的相关操作 ————————————")lst.append(x)在列表lst最后增加一个元素 lst.insert(index,x)在列表中第index位置增加一个元素 lst.clear()清除列表lst中所有元素 lst.pop(index)将列表lst中第index位置的元素取出&#xf…

C语言复习笔记--数组

今天继续来浅浅推进一下C语言的复习,这次是数组的复习,话不多说,正文开始. 数组的概念 数组是⼀组相同类型元素的集合,一种自定义类型.数组中元素个数不能为0.数组分为⼀维数组和多维数组&#xff0c;多维数组⼀般⽐较多⻅的是⼆维数组. 下面从一维数组说起. 一维数组的创建和…

Canal 解析与 Spring Boot 整合实战

一、Canal 简介 1.1 Canal 是什么&#xff1f; Canal 是阿里巴巴开源的一款基于 MySQL 数据库增量日志解析&#xff08;Binlog&#xff09;中间件&#xff0c;它模拟 MySQL 的从机&#xff08;Slave&#xff09;行为&#xff0c;监听 MySQL 主机的二进制日志&#xff08;Binl…

暗光增强技术研究进展与产品落地综合分析(2023-2025)

一、引言 暗光增强技术作为计算机视觉与移动影像领域的核心研究方向之一,近年来在算法创新、硬件适配及产品落地方面取得了显著进展。本文从技术研究与产业应用两个维度,系统梳理近三年(2023-2025)该领域的关键突破,并对比分析主流手机厂商的影像技术优劣势。 二、暗光增…

多维array和多维视图std::mdspan

多维数组 这个特性用于访问多维数组&#xff0c;之前C operator[] 只支持访问单个下标&#xff0c;无法访问多维数组。 因此要访问多维数组&#xff0c;以前的方式是&#xff1a; 重载operator()&#xff0c;于是能够以m(1, 2) 来访问第1 行第2 个元素。但这种方式容易和函数…

利用AI让数据可视化

1. 从问卷星上下载一份答题结果。 序号用户ID提交答卷时间所用时间来源来源详情来自IP总分1、《中华人民共和国电子商务法》正式实施的时间是&#xff08;&#xff09;。2、&#xff08;&#xff09;可以判断企业在行业中所处的地位。3、&#xff08;&#xff09;是指店铺内有…

【第14节】windows sdk编程:进程与线程介绍

目录 一、进程与线程概述 1.1 进程查看 1.2 何为进程 1.3 进程的创建 1.4 进程创建实例 1.5 线程查看 1.6 何为线程 1.7 线程的创建 1.8 线程函数 1.9 线程实例 二、内核对象 2.1 何为内核对象 2.2 内核对象的公共特点 2.3 内核对象句柄 2.4 内核对象的跨进程访…

Python简单爬虫实践案例

学习目标 能够知道Web开发流程 能够掌握FastAPI实现访问多个指定网页 知道通过requests模块爬取图片 知道通过requests模块爬取GDP数据 能够用pyecharts实现饼图 能够知道logging日志的使用 一、基于FastAPI之Web站点开发 1、基于FastAPI搭建Web服务器 # 导入FastAPI模…

sass介绍

1、Sass简介 Sass 是一种 CSS 的预编译语言。它提供了 变量&#xff08;variables&#xff09;、嵌套&#xff08;nested rules&#xff09;、 混合&#xff08;mixins&#xff09;、 函数&#xff08;functions&#xff09;等功能&#xff0c;并且完全兼容 CSS 语法。Sass 能…