@dcloudio/uni-quickapp-webview 2.0.1-alpha-36020220830002 → 2.0.1-alpha-36120220907001

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -12
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1298,7 +1298,11 @@ const customize = cached((str) => {
1298
1298
  function initTriggerEvent (mpInstance) {
1299
1299
  const oldTriggerEvent = mpInstance.triggerEvent;
1300
1300
  const newTriggerEvent = function (event, ...args) {
1301
- return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
1301
+ // 事件名统一转驼峰格式,仅处理:当前组件为 vue 组件、当前组件为 vue 组件子组件
1302
+ if (this.$vm || (this.dataset && this.dataset.comType)) {
1303
+ event = customize(event);
1304
+ }
1305
+ return oldTriggerEvent.apply(this, [event, ...args])
1302
1306
  };
1303
1307
  try {
1304
1308
  // 京东小程序 triggerEvent 为只读
@@ -1470,7 +1474,7 @@ function initData (vueOptions, context) {
1470
1474
  try {
1471
1475
  // 对 data 格式化
1472
1476
  data = JSON.parse(JSON.stringify(data));
1473
- } catch (e) {}
1477
+ } catch (e) { }
1474
1478
  }
1475
1479
 
1476
1480
  if (!isPlainObject(data)) {
@@ -1622,7 +1626,7 @@ function wrapper$1 (event) {
1622
1626
  // TODO 又得兼容 mpvue 的 mp 对象
1623
1627
  try {
1624
1628
  event.mp = JSON.parse(JSON.stringify(event));
1625
- } catch (e) {}
1629
+ } catch (e) { }
1626
1630
 
1627
1631
  event.stopPropagation = noop;
1628
1632
  event.preventDefault = noop;
@@ -1693,7 +1697,7 @@ function getExtraValue (vm, dataPathsArray) {
1693
1697
  return context
1694
1698
  }
1695
1699
 
1696
- function processEventExtra (vm, extra, event) {
1700
+ function processEventExtra (vm, extra, event, __args__) {
1697
1701
  const extraObj = {};
1698
1702
 
1699
1703
  if (Array.isArray(extra) && extra.length) {
@@ -1716,11 +1720,7 @@ function processEventExtra (vm, extra, event) {
1716
1720
  if (dataPath === '$event') { // $event
1717
1721
  extraObj['$' + index] = event;
1718
1722
  } else if (dataPath === 'arguments') {
1719
- if (event.detail && event.detail.__args__) {
1720
- extraObj['$' + index] = event.detail.__args__;
1721
- } else {
1722
- extraObj['$' + index] = [event];
1723
- }
1723
+ extraObj['$' + index] = event.detail ? event.detail.__args__ || __args__ : __args__;
1724
1724
  } else if (dataPath.indexOf('$event.') === 0) { // $event.target.value
1725
1725
  extraObj['$' + index] = vm.__get_value(dataPath.replace('$event.', ''), event);
1726
1726
  } else {
@@ -1747,6 +1747,12 @@ function getObjByArray (arr) {
1747
1747
 
1748
1748
  function processEventArgs (vm, event, args = [], extra = [], isCustom, methodName) {
1749
1749
  let isCustomMPEvent = false; // wxcomponent 组件,传递原始 event 对象
1750
+
1751
+ // fixed 用户直接触发 mpInstance.triggerEvent
1752
+ const __args__ = isPlainObject(event.detail)
1753
+ ? event.detail.__args__ || [event.detail]
1754
+ : [event.detail];
1755
+
1750
1756
  if (isCustom) { // 自定义事件
1751
1757
  isCustomMPEvent = event.currentTarget &&
1752
1758
  event.currentTarget.dataset &&
@@ -1755,11 +1761,11 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam
1755
1761
  if (isCustomMPEvent) {
1756
1762
  return [event]
1757
1763
  }
1758
- return event.detail.__args__ || event.detail
1764
+ return __args__
1759
1765
  }
1760
1766
  }
1761
1767
 
1762
- const extraObj = processEventExtra(vm, extra, event);
1768
+ const extraObj = processEventExtra(vm, extra, event, __args__);
1763
1769
 
1764
1770
  const ret = [];
1765
1771
  args.forEach(arg => {
@@ -1768,7 +1774,7 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam
1768
1774
  ret.push(event.target.value);
1769
1775
  } else {
1770
1776
  if (isCustom && !isCustomMPEvent) {
1771
- ret.push(event.detail.__args__[0]);
1777
+ ret.push(__args__[0]);
1772
1778
  } else { // wxcomponent 组件或内置组件
1773
1779
  ret.push(event);
1774
1780
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-quickapp-webview",
3
- "version": "2.0.1-alpha-36020220830002",
3
+ "version": "2.0.1-alpha-36120220907001",
4
4
  "description": "uni-app quickapp-webview",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -17,5 +17,5 @@
17
17
  "name": "quickapp-webview",
18
18
  "title": "快应用(Webview)版"
19
19
  },
20
- "gitHead": "c3cd2073bb4e67dcb6d6a1ac9e98a461fc4ebd33"
20
+ "gitHead": "2290dd0b6f192129af9c6be83819277dff40fc66"
21
21
  }