vue-monaco-editor icon indicating copy to clipboard operation
vue-monaco-editor copied to clipboard

how to change the code

Open flyinhigh opened this issue 7 years ago • 1 comments

the :code is the initial code to show . it works only when it renders at the first time. if I want to change the code , how can I do ?

flyinhigh avatar Jan 23 '18 14:01 flyinhigh

Use setValue() on the editor object returned by the onMounted method: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.icodeeditor.html#setvalue

The example shows how to get the editor object:

module.exports = {
  components: {
    Monaco
  },
  data() {
    return {
      code: '// Type away! \n',
      options: {
        selectOnLineNumbers: false
      }
    };
  },
  methods: {
    onMounted(editor) {
      this.editor = editor;
    },
    onCodeChange(editor) {
      console.log(editor.getValue());
    }
  }
};

zantiu avatar Jan 29 '18 23:01 zantiu