html - 当在 angular 中使用 innerHTML 属性时,光标插入符号移动到开头
问题描述
在这里,我在 contenteditable div 中使用 innerHTML 属性。问题是每当我尝试编辑内容时,插入符号光标移动到开头并反转整个文本。我应该怎么做才能像正常编辑一样将插入符号移动到结束位置?
我的 HTML 代码:
<div #editor class="editor"
style=" max-height: 200px;"
[innerHTML]="blogData.description"
(input)="onChange()"
(input)="blogData.description=$event.target.innerHTML"
name="blogData.description"
contenteditable></div>
上面的截图显示了差异,实际上我输入的是“this is”,因为光标在开头,内容看起来像这样。提前致谢。
解决方案
推荐阅读
- hyperledger-fabric - 从 Hyperledger Fabric 的通道中的 OrdererAddresses 部分中删除大多数订购者
- r - 将函数应用于所有数据框
- next.js - 在 ComponentDidMount 之后将 React.Context 传递给 Nextjs?
- elasticsearch - geo_ip kibana 索引和 logstash 过滤器
- google-cloud-platform - BigQuery 使用通配符表达式根据未来表创建视图
- spring-boot - 在 Springboot 2.2.6 中找不到 jwt 依赖项
- node.js - 在 NodeJS 中将缓冲区数据转换为 blob
- selenium - org.openqa.selenium.ElementClickInterceptedException
- spring-boot - 如果在 Spring Webflux 中启用了 CORS,则 Swagger 不起作用
- html - 如何从容器中取出一个块