Shi*_*ara 6 html javascript blur angular
我有一个可满足的div,看起来像这样:
<div class="wall-title col-sm-12"
[attr.contenteditable]="wall.title && wall.title !== 'Favorites'"
(blur)="wallNameChanged($event.target.outerText)"
(keyup.enter)="wallNameChanged($event.target.outerText)">
{{wall.title}}
</div>
Run Code Online (Sandbox Code Playgroud)
当用户在编辑div内容后按Enter键时,我想模糊div.目前,正在添加新行字符,并且在UI中可以看到新行.
我该如何实现这一目标?
在你的组件中:
onEnter($event){
$event.target.blur()
$event.preventDefault()
this.wallNameChanged($event.target.outerText)
}
Run Code Online (Sandbox Code Playgroud)
在你的模板中:
<div class="wall-title col-sm-12"
[attr.contenteditable]="wall.title && wall.title !== 'Favorites'"
(blur)="wallNameChanged($event.target.outerText)"
(keyup.enter)="onEnter($event)">
{{wall.title}}
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2460 次 |
| 最近记录: |