1
0

VueItextarea.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- <codemirror v-model="current_value" :options="cmOptions"/>-->
  3. <editor v-model="current_value" @init="editorInit" lang="nginx" theme="monokai" width="100%" height="1000"></editor>
  4. </template>
  5. <style lang="less">
  6. .cm-s-monokai {
  7. height: auto !important;
  8. }
  9. </style>
  10. <script>
  11. //import {codemirror} from 'vue-codemirror'
  12. import 'codemirror/lib/codemirror.css'
  13. import 'codemirror/theme/monokai.css'
  14. import 'codemirror/mode/nginx/nginx'
  15. export default {
  16. name: 'vue-itextarea',
  17. components: {
  18. // codemirror
  19. editor: require('vue2-ace-editor'),
  20. },
  21. props: {
  22. value: {},
  23. },
  24. model: {
  25. prop: 'value',
  26. event: 'changeValue'
  27. },
  28. watch: {
  29. value() {
  30. this.current_value = this.value ?? ''
  31. },
  32. current_value() {
  33. this.$emit('changeValue', this.current_value)
  34. }
  35. },
  36. data() {
  37. return {
  38. current_value: this.value ?? '',
  39. cmOptions: {
  40. tabSize: 4,
  41. mode: 'text/x-nginx-conf',
  42. theme: 'monokai',
  43. lineNumbers: true,
  44. line: true,
  45. highlightDifferences: true,
  46. defaultTextHeight: 1000,
  47. // more CodeMirror options...
  48. }
  49. }
  50. },
  51. methods: {
  52. editorInit: function () {
  53. require('brace/ext/language_tools') //language extension prerequsite...
  54. require('brace/mode/nginx') //language
  55. require('brace/theme/monokai')
  56. }
  57. }
  58. }
  59. </script>