py-test-component 2.0.2 → 2.0.4

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": "py-test-component",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Vue2 + ElementUI 组件库,支持 React 使用",
5
5
  "main": "dist/py-component.js",
6
6
  "module": "dist/py-component.esm.js",
@@ -21,7 +21,10 @@
21
21
  "files": [
22
22
  "dist",
23
23
  "src/react",
24
- "README.md","USAGE.md","DEVELOPER.md","src/vue"
24
+ "README.md",
25
+ "USAGE.md",
26
+ "DEVELOPER.md",
27
+ "src/vue"
25
28
  ],
26
29
  "scripts": {
27
30
  "build": "webpack --mode production",
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef, useState, forwardRef } from 'react';
1
+ import React, { useEffect, useRef, useState, forwardRef } from 'react';
2
2
 
3
3
  // 注入 ElementUI CSS(只执行一次)
4
4
  let cssInjected = false;
@@ -16,7 +16,7 @@ function usePyComponent() {
16
16
  const [loaded, setLoaded] = useState(false);
17
17
  useEffect(() => {
18
18
  injectElementUICSS();
19
- import('../../dist/py-component.esm.js').then(() => setLoaded(true));
19
+ import('py-test-component').then(() => setLoaded(true));
20
20
  }, []);
21
21
  return loaded;
22
22
  }
@@ -37,7 +37,8 @@ function wrapVueComponent(tagName, dataProp = null) {
37
37
  return <div style={{ padding: '20px', textAlign: 'center' }}>{loading}</div>;
38
38
  }
39
39
 
40
- return <tagName ref={ref || elRef} {...props} />;
40
+ // 使用 createElement 避免 JSX 标签名大小写警告
41
+ return React.createElement(tagName, { ref: ref || elRef, ...props });
41
42
  });
42
43
  }
43
44
 
@@ -47,7 +48,7 @@ export const PyWeather = wrapVueComponent('py-weather', 'propData');
47
48
 
48
49
  // 初始化 store(仅设置,不暴露 store 给外部)
49
50
  export function initStore(config) {
50
- return import('../../dist/py-component.esm.js').then((m) => {
51
+ return import('py-test-component').then((m) => {
51
52
  const PyComponent = m.default || m;
52
53
  PyComponent?.initStore?.(config);
53
54
  });