在不选择整个编辑器的情况下为 ace 编辑器设置值 [英] Set Value for ace editor without selecting the whole editor

查看:26
本文介绍了在不选择整个编辑器的情况下为 ace 编辑器设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此您可以使用 setValue 设置 ace 编辑器的值,但是在设置值后,编辑器将选择编辑器的整个值.你如何禁用这个?这意味着当我将 ace editor 的值设置为 Hello world 时,它不会突出显示 Hello world

So you can set value of an ace editor with setValue but after setting the value, the editor will select the whole value of the editor. How do you disable this? This mean when I set value of ace editor to Hello world, it won't highlight Hello world

推荐答案

可以使用setValue后的第二个参数来控制光标位置

You can use the second parameter to control cursor position after setValue

editor.setValue(str, -1) // moves cursor to the start
editor.setValue(str, 1) // moves cursor to the end

这篇关于在不选择整个编辑器的情况下为 ace 编辑器设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆