Closed zhoufanglu closed 2 years ago
i slove it
// 引入代码自动提示插件
import "codemirror/addon/hint/show-hint.css";
import "codemirror/addon/hint/sql-hint";
import "codemirror/addon/hint/show-hint";
const opts = {
// ...
extraKeys: {
// 触发按键
Ctrl: "autocomplete",
Tab: "autocomplete",
},
hintOptions: {
// 自定义提示选项
completeSingle: false, // 当匹配只有一项的时候是否自动补全
},
}
how to get codemitter instance?
const codeMirrorRef = ref(null);
codeMirrorRef.value.showHint() // TypeError: codeMirrorRef.value.showHint is not a function
ready事件或者ref获取
refName.value.cminstance
ready事件或者ref获取
refName.value.cminstance
codeMirrorRef.value.cminstance.showHint();
谢谢大佬 确实可行
大佬我有个疑问, 我现在监听的codeChange, 一触发我就showHint(); 如何在输入回车的时候隐藏hint
does someone know how to take control over what exactly autocompleted? register own global variables and etc?
大佬我有个疑问, 我现在监听的codeChange, 一触发我就showHint(); 如何在输入回车的时候隐藏hint
<Codemirror
v-model:value="code"
:options="cmOptions"
border
@change="onChange"
@ready="onReady"
@keypress="showEditorHint"
ref="codeMirrorRef"
>
...
const codeMirrorRef = ref()
function showEditorHint(e: KeyboardEvent, handle: Function){
console.log('e',e)
codeMirrorRef.value.cminstance.showHint();
}
我这样好像不会回车的时候出现代码提示
Have a demo?