FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.19k stars 127 forks source link

v-show not work #210

Closed yangxyo closed 4 days ago

yangxyo commented 1 week ago

v-show not work

FranckFreiburger commented 4 days ago

v-show seems to work fine:

<!DOCTYPE html>
<html>
<body>
  <script src="https://unpkg.com/vue@3/dist/vue.runtime.global.prod.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vue3-sfc-loader@0.9.5/dist/vue3-sfc-loader.js"></script>
  <script>
    //<!--
    const options = {
      moduleCache: { vue: Vue },
      getFile: () => `
        <template>
          <span v-show="test">visible</span>
          <button @click="test = !test">toggle</button>
        </template>
        <script setup>
          import { ref } from 'vue'
          const test = ref(true);
        </script>
      `,
      addStyle: () => {},
    }
    Vue.createApp(Vue.defineAsyncComponent(() => window['vue3-sfc-loader'].loadModule('file.vue', options))).mount(document.body);
    //-->
  </script>
</body>
</html>