suncy-my-npm-test 1.0.47 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suncy-my-npm-test",
3
- "version": "1.0.47",
3
+ "version": "1.0.49",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/suncy-my-npm-test.umd.js",
@@ -11,10 +11,12 @@
11
11
  "import": "./dist/suncy-my-npm-test.es.js",
12
12
  "require": "./dist/suncy-my-npm-test.umd.js"
13
13
  },
14
- "./dist/*": "./dist/*"
14
+ "./dist/*": "./dist/*",
15
+ "./vue2": "./src/vue2-wrapper.js"
15
16
  },
16
17
  "files": [
17
- "dist"
18
+ "dist",
19
+ "src/vue2-wrapper.js"
18
20
  ],
19
21
  "types": "dist/index.d.ts",
20
22
  "peerDependencies": {
@@ -0,0 +1,29 @@
1
+ import Vue from 'vue'
2
+
3
+ // Vue 2 兼容性包装
4
+ export const Vue2Plugin = {
5
+ install(Vue, options) {
6
+ // 动态加载 Web Components
7
+ const script = document.createElement('script')
8
+ script.src = options.cdnUrl || './my-vue-webcomponents.umd.js'
9
+ document.head.appendChild(script)
10
+
11
+ // 组件加载完成后注册
12
+ script.onload = () => {
13
+ // 通过全局变量访问组件
14
+ if (window.MyWebComponents && window.MyWebComponents.register) {
15
+ window.MyWebComponents.register()
16
+ }
17
+ }
18
+
19
+ // 也可以提供 Vue 2 组件版本
20
+ // Vue.component('MyButton', {
21
+ // props: ['type'],
22
+ // template: `
23
+ // <my-button :type="type" @click="$emit('click')">
24
+ // <slot></slot>
25
+ // </my-button>
26
+ // `,
27
+ // })
28
+ },
29
+ }