Giter VIP home page Giter VIP logo

Comments (6)

Rainboylvx avatar Rainboylvx commented on May 30, 2024 1

我在build过程种,还是报错了SyntaxError: Unexpected token: operator (>) [./~/.1.0.4@vue-codemirror/es6.js

我把index 中
require(es6.js) 去掉后 就可以了

from vue-codemirror.

zchrissirhcz avatar zchrissirhcz commented on May 30, 2024

应该是es6的问题。index.js中都是es6写法,缺少对于es6的配置项。

from vue-codemirror.

zchrissirhcz avatar zchrissirhcz commented on May 30, 2024

或者临时替换为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

from vue-codemirror.

surmon-china avatar surmon-china commented on May 30, 2024

稍后更新,感谢反馈

from vue-codemirror.

surmon-china avatar surmon-china commented on May 30, 2024

已更新

from vue-codemirror.

surmon-china avatar surmon-china commented on May 30, 2024

已经修复,请更新

from vue-codemirror.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.