@@ -67,21 +67,24 @@ export default {
67
67
<codemirror ></codemirror >
68
68
69
69
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 -->
75
73
<codemirror :code.sync =" code" :options =" editorOption" ></codemirror >
76
74
77
75
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 -->
79
82
<codemirror :code =" code" :options =" editorOption" @changed =" codeChange" ></codemirror >
80
83
```
81
84
82
85
83
86
``` javascript
84
- // editorOption example:
87
+ // editor option example:
85
88
export default {
86
89
data () {
87
90
return {
@@ -90,13 +93,13 @@ export default {
90
93
tabSize: 4 ,
91
94
mode: ' text/javascript' ,
92
95
theme: ' base16-dark' ,
93
- lineNumbers: true ,
96
+ lineNumbers: true ,
94
97
line: true ,
95
98
...
96
99
}
97
100
}
98
101
},
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
100
103
methods: {
101
104
codeChange (newCode ) {
102
105
console .log (newCode)
@@ -118,8 +121,8 @@ mode: {
118
121
```
119
122
120
123
``` 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 >
123
126
```
124
127
125
128
``` javascript
@@ -139,7 +142,7 @@ data () {
139
142
140
143
[ Codemirror themes] ( http://codemirror.net/demo/theme.html )
141
144
142
- [ Codemirror language modes] ( http://codemirror.net/mode/ )
145
+ [ Codemirror language modes] ( http://codemirror.net/mode/ ) (MIME types defined)
143
146
144
147
145
148
0 commit comments