Closed zchrissirhcz closed 7 years ago
应该是es6的问题。index.js
中都是es6写法,缺少对于es6的配置项。
或者临时替换为es5的写法,当然也最好符合eslint标准:
/**
* Vue-CodeMirror
* @author Surmon.me
* @date 2016-9-22
*/
'use strict'
const CodeMirror = require('codemirror/lib/codemirror.js')
require('codemirror/lib/codemirror.css')
const CmComponentBuild = function (Vue) {
const CmComponent = Vue.extend({
template: '<textarea></textarea>',
data: function () {
return {
content: ''
}
},
props: {
code: String,
options: {
type: Object,
default: function () {
return {
styleActiveLine: true,
lineNumbers: true,
mode: 'javascript',
lineWrapping: true
}
}
}
},
created: function () {
this.options = this.options || {}
const language = this.options.mode || 'javascript'
const theme = this.options.theme
require('codemirror/mode/' + language + '/' + language + '.js')
if (!!theme && theme !== 'default') require('codemirror/theme/' + theme + '.css')
},
ready: function () {
this.editor = CodeMirror.fromTextArea(this.$el, this.options)
this.editor.setValue(this.code || this.content)
this.editor.on('change', function (cm) {
this.content = cm.getValue()
this.code = cm.getValue()
})
},
watch: {
'code': function (newVal, oldVal) {
// console.log('update', newVal)
// this.editor.setValue(newVal)
// this.content = newVal
}
}
})
Vue.component('codemirror', CmComponent)
}
const codemirror = {
install: function (Vue) {
CmComponentBuild(Vue)
}
}
module.exports = codemirror
稍后更新,感谢反馈
已更新
我在build过程种,还是报错了SyntaxError: Unexpected token: operator (>) [./~/.1.0.4@vue-codemirror/es6.js
我把index 中 require(es6.js) 去掉后 就可以了
已经修复,请更新
我把
vue-codemirror
在自己项目中装好后,buld
阶段报错:有什么建议吗?
我的
package.json
中有配置babel
相关的包: