Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript CodeMirror custom showHint()调用不';行不通_Javascript_Plugins_Editor_Wysiwyg_Codemirror - Fatal编程技术网

Javascript CodeMirror custom showHint()调用不';行不通

Javascript CodeMirror custom showHint()调用不';行不通,javascript,plugins,editor,wysiwyg,codemirror,Javascript,Plugins,Editor,Wysiwyg,Codemirror,试图实现拼写检查模块的自定义showHint调用。我遵循了但是调用编辑器。showHint似乎什么也不做,并返回未定义的 我想我遗漏了一些东西。下面是我要测试的沙盒代码: editor.on('cursorActivity', function() { var options = { from: editor.getDoc().getCursor(), to: editor.getDoc().getCursor(), list: ['foo', 'bar', 'b

试图实现拼写检查模块的自定义
showHint
调用。我遵循了但是调用
编辑器。showHint
似乎什么也不做,并返回
未定义的

我想我遗漏了一些东西。下面是我要测试的沙盒代码:

editor.on('cursorActivity', function() {
    var options = {
    from: editor.getDoc().getCursor(),
    to: editor.getDoc().getCursor(),
    list: ['foo', 'bar', 'baz']
  };
  editor.showHint(options);
});

好的,根据文档解决我的问题:

查找提示是通过提示函数(提示选项)完成的,提示函数接受编辑器实例和选项对象,并返回{list,from,to}对象

不是将
传递到
列表
传递到
showHint(选项)
,而是必须从传递到
showHint
hint
函数返回它们


好的,根据文档,解决了我的问题:

查找提示是通过提示函数(提示选项)完成的,提示函数接受编辑器实例和选项对象,并返回{list,from,to}对象

不是将
传递到
列表
传递到
showHint(选项)
,而是必须从传递到
showHint
hint
函数返回它们

editor.on('cursorActivity', function() {
  var options = {
    hint: function() {
      return {
        from: editor.getDoc().getCursor(),
          to: editor.getDoc().getCursor(),
        list: ['foo', 'bar']
      }
    }
  };
  editor.showHint(options);
});