VueItextarea.vue 1.1 KB

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