Closed VancySavoki closed 7 years ago
Yes, you are right.
// you can also introduce the resource pack you want to use within the component
// require ('codemirror/some-resource')
https://github.com/surmon-china/vue-codemirror/blob/master/examples/02-text-javascript.vue#L53
When I use this components refer to README.md example,the browser console print this warn,and the vue-codemirror component could not work!
[Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'attach' of undefined" TypeError: Cannot read property 'attach' of undefined(…)
when I debug it, found in codemirror.js:7480 7480 option("keyMap", "default", function (cm, val, old) { 7481 var next = getKeyMap(val); 7482 var prev = old != Init && getKeyMap(old); 7483 if (prev && prev.detach) { prev.detach(cm, next); } 7484 if (next.attach) { next.attach(cm, prev || null); } 7585 }); In example, the keyMap option is set to sublime,but not import the correct sublime keymap. when getKeyMap by val(In eg,val == sublime),the variable 'next' got null! So
next.attach
will throw a exception of 'TypeError: Cannot read property 'attach' of undefined' To resolve it,must import the correct keymap as below import 'codemirror/keymap/sublime' or require('codemirror/keymap/sublime') dynamicly