Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy loading modes doesn't work #29

Closed
kldzj opened this issue May 6, 2017 · 3 comments
Closed

Lazy loading modes doesn't work #29

kldzj opened this issue May 6, 2017 · 3 comments

Comments

@kldzj
Copy link

kldzj commented May 6, 2017

Hi there,

there seems to be a problem when trying to lazy load modes like in the CodeMirror example.

this.$refs.codemirror.editor.setOption('mode', syntax);
CodeMirror.autoLoadMode(this.$refs.codemirror.editor, syntax);

syntax in this case would be 'text/x-php' or any other of the supported language mime types.

TypeError: CodeMirror.autoLoadMode is not a function

Is this a known problem or is some workaround needed? :)

@surmon-china
Copy link
Owner

require('codemirror/mode/php/php.js')
require('codemirror/addon/mode/loadmode.js')
// your options
// ...
// get the mode by findModeByName || findModeByExtension || findModeByMIME || findModeByFileName
// like: view-source:https://codemirror.net/demo/loadmode.html
const syntax = 'php'
this.$refs.codemirror.editor.setOption('mode', syntax)
CodeMirror.autoLoadMode(this.$refs.codemirror.editor, syntax)

@kieuminhcanh
Copy link

It's not lazy loading anymore when code like that.

@zhangchunlin
Copy link

Now I cannot get editor property in codemirror obj:

                    var cm = vm.$refs.srccode
                    console.log(cm)
                    console.log(cm.editor)

The result:

VueComponent {_uid: 1, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …}     (index):164
undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants