npm install -- save- dev vue2- ace- editor
import Editor from 'vue2-ace-editor' ;
Vue. use ( Editor)
import Editor from 'vue2-ace-editor' ;
components : {
Editor,
} ,
< template>
< div class = "codeEditBox" >
< editor
v- model= "code"
@init= "editorInit"
@input= "codeChange"
lang= "javascript"
: options= "editorOptions"
theme= "chrome"
> < / editor>
< / div>
< / template>
< script>
import Editor from 'vue2-ace-editor'
export default {
components : {
Editor,
} ,
data ( ) {
return {
code : '' ,
editorOptions : {
enableBasicAutocompletion : true ,
enableSnippets : true ,
enableLiveAutocompletion : true ,
tabSize : 2 ,
fontSize : 18 ,
showPrintMargin : false ,
} ,
}
} ,
methods : {
codeChange ( val ) {
console. log ( val)
} ,
editorInit ( ) {
} ,
} ,
}
< / script>
< style scoped>
. codeEditBox {
width : 100 % ;
height : 200px;
border : 1px solid #dcdee2;
}
. ace_content {
line- height: 20px;
font- size: 12px;
color : pink;
}
< / style>