test

151 阅读1分钟
    import content from './example'
import { codemirror } from 'vue-codemirror'
import 'codemirror/lib/codemirror.css'

function aaa {
    let a= 1;
}

const Component = {

    name: 'markdown-panel',

    components: {
        codemirror
    },

    watch: {

        content (v) {
            this.$store.commit('markdownContent', v)
        }

    },

    data () {

        return {
            content,
            code: '# aaa',
            cmOptions: {
                // codemirror options
                tabSize: 4,
                mode: 'text/javascript',
                theme: 'base16-dark',
                lineNumbers: true,
                line: true,
                // more codemirror options, 更多 codemirror 的高级配置...
            }
        }

    },

    methods: {
        onCmReady(cm) {
            console.log('the editor is readied!', cm)
        },
        onCmFocus(cm) {
            console.log('the editor is focus!', cm)
        },
        onCmCodeChange(newCode) {
            console.log('this is new code', newCode)
            this.code = newCode
        }
    },
    computed: {
        codemirror() {
            return this.$refs.myCm.codemirror
        }
    },
    mounted() {
        console.log('this is current codemirror object', this.codemirror)
        // you can use this.codemirror to do something...
    },

    created () {
        this.$store.commit('markdownContent', content)
    }

};

export default Component