vue-web-component-wrapper使用 Vue 開(kāi)發(fā) Web 組件
vue-web-component-wrapper 是一個(gè)使用 Vue 來(lái)開(kāi)發(fā) Web Components 的 JavaScript 庫(kù),支持大部分常用的 Vue API。
import Vue from 'vue'
import wrap from '@vue/web-component-wrapper'
const Component = {
// any component options
}
const CustomElement = wrap(Vue, Component)
window.customElements.define('my-element', CustomElement)
請(qǐng)注意,以這種方式構(gòu)建的 Web Components 會(huì)依賴(lài) Vue 的 runtime,這意味著最少會(huì)有 16kb 的 runtime 代碼被引入。
評(píng)論
圖片
表情
