尝试为拼写检查模块实现自定义 showHint
调用。我已经关注了docs但调用 editor.showHint
似乎没有执行任何操作并返回 undefined
。
我想我缺少一些东西。这是我要测试的沙箱代码:
editor.on('cursorActivity', function() {
var options = {
from: editor.getDoc().getCursor(),
to: editor.getDoc().getCursor(),
list: ['foo', 'bar', 'baz']
};
editor.showHint(options);
});
最佳答案
好的,根据文档解决了我的问题:
Finding hints is done with a hinting functions (the hint option), which is a function that take an editor instance and options object, and return a {list, from, to} object
必须返回它们,而不是将 from
、to
和 list
传递到 showHint(options)
从传递到 showHint
的 hint
函数。
http://jsfiddle.net/3wvcudqt/4/
editor.on('cursorActivity', function() {
var options = {
hint: function() {
return {
from: editor.getDoc().getCursor(),
to: editor.getDoc().getCursor(),
list: ['foo', 'bar']
}
}
};
editor.showHint(options);
});
关于javascript - CodeMirror 自定义 showHint() 调用不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36553748/