vuejs / repl

Vue SFC REPL as a Vue 3 component
https://repl-vuejs.vercel.app
MIT License
930 stars 172 forks source link

Why do different `Repl` instances affect each other? , it looks like the same reference is used internally in the editor #146

Closed ckvv closed 1 year ago

ckvv commented 1 year ago

截屏2023-08-09 17 16 14

<!-- TestEditor -->
<script setup>
import '@vue/repl/style.css';
import { Repl, ReplStore } from '@vue/repl';
import Monaco from '@vue/repl/monaco-editor';
import { ref, watch } from 'vue';

const code = ref(`<template>11</template>`)

const store = new ReplStore();

watch(code, (v) => {
  store.setFiles({'src/App.vue': v})
}, {
  immediate: true
});
</script>

<template>
  <div>
    <input type="text" v-model="code">
    <Repl :editor="Monaco" :store="store" :clear-console="false" />
  </div>
</template>
<template>
  <div>
    <TestEditor />
    <TestEditor />
  </div>
</template>
troy351 commented 1 year ago

monaco manages all files in one context and it is by designed, which means the same Uri of file will result in one identical model. You may try different file paths