Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

264
Views
en caso de que tenga varios editores de diferencias de Mónaco en la misma página, las diferencias solo serán visibles en primera instancia

Tengo un componente Vue que renderiza el editor de diferencias de Mónaco. Una vez que tengo más de una instancia en la misma página, la diferencia solo se muestra en la primera.

modelo:

 <template> <div> <div ref="diffEditor" class="vue--monaco-diff-editor"></div> </div> </template>

guion:

 async mounted(): Promise<void> { await this.importMonacoPackage(); this.$nextTick(() => { if (!monaco) { throw new Error('monaco is not initialized'); } const originalModel = monaco.editor.createModel( this.versions[0].code, MonacoHelper.markdownLangToMonacoLang(this.versions[0].lang), ); const modifiedModel = monaco.editor.createModel( this.versions[1].code, MonacoHelper.markdownLangToMonacoLang(this.versions[1].lang), ); let diffEditorElement = this.$refs.diffEditor; this.diffEditor = monaco.editor.createDiffEditor( diffEditorElement as HTMLElement, { scrollbar: { vertical: 'hidden', horizontal: 'hidden', handleMouseWheel: true, }, wordWrap: 'on', readOnly: true, scrollBeyondLastLine: false, minimap: { enabled: false, }, automaticLayout: true, }, ); if (!this.diffEditor) { return; } this.diffEditor.setModel({ original: originalModel, modified: modifiedModel, }); // set the editor height to scale with the content height automatically // see https://github.com/microsoft/monaco-editor/issues/794 const originalContentHeight = this.diffEditor .getOriginalEditor() .getContentHeight(); const modifiedContentHeight = this.diffEditor .getModifiedEditor() .getContentHeight(); let contentHeight = Math.max( originalContentHeight, modifiedContentHeight, ); // allow for a single empty line at the bottom, default line height is 18px contentHeight = contentHeight + 18; const domNode = this.diffEditor.getDomNode(); domNode.style.height = `${contentHeight}px`; this.diffEditor.layout(); }); }, methods: { async importMonacoPackage() { // eslint-disable-next-line import/no-unresolved monaco = await import('../../../lib/monaco-editor'); }, },

Estoy usando
"monaco-editor": "^0.24.0","vue": "^2.6.13". alguna idea de lo que estoy haciendo mal? ¿Y por qué solo la primera instancia muestra los aspectos más destacados de la diferencia?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!