vuejs / composition-api

Composition API plugin for Vue 2
https://composition-api.vuejs.org/
MIT License
4.19k stars 342 forks source link

not work nice in web component, no error #973

Closed DULANGHAI closed 1 year ago

DULANGHAI commented 1 year ago

when i try to build web components by vue-cli, components that use @vue/composition-api not work nice

I have a demo component like this

<template>
  <div>{{ timeText }}</div>
</template>

<script lang="ts">
import VueCompositionAPI, {
  computed,
  defineComponent,
} from "@vue/composition-api";
import Vue from "vue";

Vue.use(VueCompositionAPI);

export default defineComponent({
  props: {
    time: {
      type: [Number, String],
      default: 0,
    },
  },
  setup(props) {
    const timeText = computed(() => {
      return +props.time + +new Date() + "";
    });
    return {
      timeText,
    };
  },
});
</script>

copy to add another one component, then build web components

"test": "vue-cli-service build --target wc-async --name test-count './src/test/count.vue'",
"test2": "vue-cli-service build --target wc-async --name test-count2 './src/test/count.vue'",

import file

<script src="<%= BASE_URL %>test-count/test-count.js"></script>
<script src="<%= BASE_URL %>test-count2/test-count2.js"></script>

use in vue

<template>
  <div>
    <test-count time="108000000"></test-count>
    <test-count2 time="108000000"></test-count2>
  </div>
</template>

what i saw is

image

I don`t see any error。It really bothers me, help please

It seems the web components entry file load latest work well

DULANGHAI commented 1 year ago

@antfu Have you ever encountered this problem

github-actions[bot] commented 1 year ago

Stale issue message