@@ -67,21 +67,24 @@ export default {
6767<codemirror ></codemirror >
6868
6969
70- <!-- component data bind(Vue.js1.X) -->
71- <codemirror :code.sync =" code" ></codemirror >
72-
73-
74- <!-- component config example 1(Vue.js1.X) -->
70+ <!-- component data bind and config in Vue.js1.X -->
71+ <codemirror :code =" code" :options =" editorOption" ></codemirror >
72+ <!-- Bidirectional data binding in Vue.js1.X -->
7573<codemirror :code.sync =" code" :options =" editorOption" ></codemirror >
7674
7775
78- <!-- in vue.js2.X .once and .sync are deprecated, parent component needs to explicitly emit an event instead of relying on implicit binding -->
76+ <!-- component data bind and config in Vue.js2.X -->
77+ <codemirror :code =" code" :options =" editorOption" ></codemirror >
78+ <!-- Bidirectional data binding in Vue.js2.X -->
79+ <codemirror v-model =" code" :options =" editorOption" ></codemirror >
80+ <!-- or -->
81+ <!-- If you need to manually control the data synchronization, you can monitor the code change event like this -->
7982<codemirror :code =" code" :options =" editorOption" @changed =" codeChange" ></codemirror >
8083```
8184
8285
8386``` javascript
84- // editorOption example:
87+ // editor option example:
8588export default {
8689 data () {
8790 return {
@@ -90,13 +93,13 @@ export default {
9093 tabSize: 4 ,
9194 mode: ' text/javascript' ,
9295 theme: ' base16-dark' ,
93- lineNumbers: true ,
96+ lineNumbers: true ,
9497 line: true ,
9598 ...
9699 }
97100 }
98101 },
99- // if you use in vue2.X, parent component needs to explicitly emit an event instead of relying on implicit binding
102+ // If you need to manually control the data synchronization, parent component needs to explicitly emit an event instead of relying on implicit binding
100103 methods: {
101104 codeChange (newCode ) {
102105 console .log (newCode)
@@ -118,8 +121,8 @@ mode: {
118121```
119122
120123``` html
121- <!-- component config example 2(Vue.js1.X) -->
122- <codemirror :code.sync =" css" :options =" { tabSize: 2, mode: 'css' }" ></codemirror >
124+ <!-- component config example 2 (Vue.js1.X) -->
125+ <codemirror :code.sync =" css" :options =" { tabSize: 2, mode: 'text/ css' }" ></codemirror >
123126```
124127
125128``` javascript
@@ -139,7 +142,7 @@ data () {
139142
140143[ Codemirror themes] ( http://codemirror.net/demo/theme.html )
141144
142- [ Codemirror language modes] ( http://codemirror.net/mode/ )
145+ [ Codemirror language modes] ( http://codemirror.net/mode/ ) (MIME types defined)
143146
144147
145148
0 commit comments