ACE代码编辑器,代码提示,添加自定义数据
//设置自动提示代码 var setCompleteData = function(data) { var langTools = ace.require("ace/ext/language_tools"); langTools.addCompleter({ getCompletions: function(editor, session, pos, prefix, callback) { if (prefix.length === 0) { return callback(null, []); } else { return callback(null, data); } } }); }
其中参数data为数组,其的格式为:
1 [{meta: "abcdefg", caption: "sonic", value: "sonic", score:1}]
效果为: