Skip to content

VueCompositionAPI not work nice, no error #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
DULANGHAI opened this issue Nov 29, 2022 · 4 comments
Open

VueCompositionAPI not work nice, no error #124

DULANGHAI opened this issue Nov 29, 2022 · 4 comments

Comments

@DULANGHAI
Copy link

DULANGHAI commented Nov 29, 2022

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

@DULANGHAI
Copy link
Author

It seems the web components entry file load latest work well

@DULANGHAI
Copy link
Author

@karol-f Have you ever encountered this problem?

@karol-f
Copy link

karol-f commented Dec 2, 2022

@karol-f Have you ever encountered this problem?

Unfortunately not. But anyway, while using e.g. Vue@3 you should have Web Components support out of the box - https://vuejs.org/guide/extras/web-components.html#building-custom-elements-with-vue

@DULANGHAI
Copy link
Author

@karol-f Have you ever encountered this problem?

Unfortunately not. But anyway, while using e.g. Vue@3 you should have Web Components support out of the box - https://vuejs.org/guide/extras/web-components.html#building-custom-elements-with-vue

but I have many components used composition-api and vue < 2.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants