Vue 组件转换成web component

宋安晏
2023-12-01

https://vuejsdevelopers.com/2018/05/21/vue-js-web-component/

https://github.com/vuejs/vue-web-component-wrapper

import Vue from 'vue';
import wrap from '@vue/web-component-wrapper';
import VueWebComponent from './components/Hellow';
const CustomElement = wrap(Vue, VueWebComponent);
window.customElements.define('my-custom-element', CustomElement);

 

 

 

hellow.vue

<template>
    <div>
        <h1>My Vue Web Component</h1>
        <div>{{ msg }}</div>
        <div>{{ list }}</div>
    </div>
</template>
<script>
export default {
    props: ['msg', 'list']
};
</script>
 类似资料: