@dolphinweex/weex-harmony 0.1.69 → 0.1.71
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
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
ref="embedElement"
|
|
8
8
|
:id="embedId"
|
|
9
9
|
:type="embedType"
|
|
10
|
-
width="100%"
|
|
11
|
-
height="100%"
|
|
10
|
+
:width="embedWidth || '100%'"
|
|
11
|
+
:height="embedHeight || '100%'"
|
|
12
12
|
/>
|
|
13
13
|
</div>
|
|
14
14
|
</template>
|
|
@@ -47,6 +47,14 @@ export default {
|
|
|
47
47
|
required: false,
|
|
48
48
|
default: false,
|
|
49
49
|
},
|
|
50
|
+
embedWidth:{
|
|
51
|
+
type: String || Number,
|
|
52
|
+
defalut: '100%'
|
|
53
|
+
},
|
|
54
|
+
embedHeight:{
|
|
55
|
+
type: String || Number,
|
|
56
|
+
defalut: '100%'
|
|
57
|
+
}
|
|
50
58
|
},
|
|
51
59
|
data() {
|
|
52
60
|
return {
|
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<BaseSameLayer
|
|
3
3
|
:hosSameLayerArgs="hosSameLayerArgs"
|
|
4
|
+
ref="sameLayer"
|
|
4
5
|
embedType="native/midea-ijkplayer-view"
|
|
5
|
-
:defaultWidth="
|
|
6
|
-
:defaultHeight="
|
|
6
|
+
:defaultWidth="'100%'"
|
|
7
|
+
:defaultHeight="'100%'"
|
|
8
|
+
:embedWidth="embedWidth"
|
|
9
|
+
:embedHeight="embedHeight"
|
|
10
|
+
:style="
|
|
11
|
+
embedPosition !== 'fixed'
|
|
12
|
+
? { position: embedPosition }
|
|
13
|
+
: {
|
|
14
|
+
position: embedPosition,
|
|
15
|
+
top: 0,
|
|
16
|
+
left: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
right: 0,
|
|
19
|
+
}
|
|
20
|
+
"
|
|
7
21
|
></BaseSameLayer>
|
|
8
22
|
</template>
|
|
9
23
|
|
|
10
24
|
<script>
|
|
11
|
-
import BaseSameLayer from
|
|
25
|
+
import BaseSameLayer from './baseSameLayer.vue';
|
|
12
26
|
|
|
13
27
|
export default {
|
|
14
28
|
data() {
|
|
15
29
|
return {
|
|
16
30
|
width: 0,
|
|
17
31
|
height: 0,
|
|
32
|
+
embedWidth: '100%',
|
|
33
|
+
embedHeight: '100%',
|
|
34
|
+
embedPosition: 'static',
|
|
35
|
+
defaultWidth: '100%',
|
|
36
|
+
defaultHeight: '100%',
|
|
18
37
|
};
|
|
19
38
|
},
|
|
20
|
-
name:
|
|
39
|
+
name: 'MideaIjkplayerView',
|
|
21
40
|
components: {
|
|
22
41
|
BaseSameLayer,
|
|
23
42
|
},
|
|
@@ -34,6 +53,82 @@ export default {
|
|
|
34
53
|
return {};
|
|
35
54
|
},
|
|
36
55
|
},
|
|
56
|
+
config: {
|
|
57
|
+
type: Object,
|
|
58
|
+
default() {
|
|
59
|
+
return {};
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
muted: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false,
|
|
65
|
+
},
|
|
66
|
+
playStatus: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: 'normal',
|
|
69
|
+
},
|
|
70
|
+
needDownload: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false,
|
|
73
|
+
},
|
|
74
|
+
isSupportScale: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false,
|
|
77
|
+
},
|
|
78
|
+
videoResize: {
|
|
79
|
+
type: Number,
|
|
80
|
+
default: 0,
|
|
81
|
+
},
|
|
82
|
+
autoplay: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false,
|
|
85
|
+
},
|
|
86
|
+
videoCover: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: '',
|
|
89
|
+
},
|
|
90
|
+
uiVisible: {
|
|
91
|
+
type: Object,
|
|
92
|
+
default() {
|
|
93
|
+
return {
|
|
94
|
+
voiceBtnVisible: true,
|
|
95
|
+
speedBtnVisible: true,
|
|
96
|
+
captureBtnVisible: true,
|
|
97
|
+
downloadBtnVisible: true,
|
|
98
|
+
batteryTimeLayoutVisible: false,
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
speedList: {
|
|
103
|
+
type: Array,
|
|
104
|
+
default() {
|
|
105
|
+
return ['0.5', '1', '1.5', '2'];
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
extraInfo: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: '',
|
|
111
|
+
},
|
|
112
|
+
deleteBtnVisible: {
|
|
113
|
+
type: Number,
|
|
114
|
+
default: 0,
|
|
115
|
+
},
|
|
116
|
+
downloadDir: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: '',
|
|
119
|
+
},
|
|
120
|
+
albumName: {
|
|
121
|
+
type: String,
|
|
122
|
+
default: '',
|
|
123
|
+
},
|
|
124
|
+
src: {
|
|
125
|
+
type: String,
|
|
126
|
+
default: '',
|
|
127
|
+
},
|
|
128
|
+
isShowTopRightViewOnPortrait: {
|
|
129
|
+
type: Boolean,
|
|
130
|
+
default: false,
|
|
131
|
+
},
|
|
37
132
|
},
|
|
38
133
|
computed: {
|
|
39
134
|
hosSameLayerArgs() {
|
|
@@ -41,53 +136,104 @@ export default {
|
|
|
41
136
|
...this.hosUniqueProps, // 鸿蒙原生组件独有属性
|
|
42
137
|
width: this.width,
|
|
43
138
|
height: this.height,
|
|
139
|
+
onFullscreenChange: this.onFullscreenChange,
|
|
140
|
+
// 视频播放器相关属性
|
|
141
|
+
config: this.config,
|
|
142
|
+
muted: this.muted,
|
|
143
|
+
playStatus: this.playStatus,
|
|
144
|
+
needDownload: this.needDownload,
|
|
145
|
+
isSupportScale: this.isSupportScale,
|
|
146
|
+
videoResize: this.videoResize,
|
|
147
|
+
autoplay: this.autoplay,
|
|
148
|
+
videoCover: this.videoCover,
|
|
149
|
+
uiVisible: this.uiVisible,
|
|
150
|
+
speedList: this.speedList,
|
|
151
|
+
extraInfo: this.extraInfo,
|
|
152
|
+
deleteBtnVisible: this.deleteBtnVisible,
|
|
153
|
+
downloadDir: this.downloadDir,
|
|
154
|
+
albumName: this.albumName,
|
|
44
155
|
data: this.data,
|
|
156
|
+
src: this.src,
|
|
157
|
+
isShowTopRightViewOnPortrait: this.isShowTopRightViewOnPortrait,
|
|
45
158
|
|
|
159
|
+
// 事件回调
|
|
46
160
|
onProgress: this.onProgress,
|
|
47
161
|
onStart: this.onStart,
|
|
48
162
|
onPause: this.onPause,
|
|
49
163
|
finish: this.finish,
|
|
50
164
|
onFail: this.onFail,
|
|
51
|
-
onReadyToPlay: this.onReadyToPlay
|
|
165
|
+
onReadyToPlay: this.onReadyToPlay,
|
|
166
|
+
deleteVideo: this.deleteVideo,
|
|
167
|
+
onDownloadSuccess: this.onDownloadSuccess,
|
|
168
|
+
onStartDownload: this.onStartDownload,
|
|
169
|
+
onPreviewImageClick: this.onPreviewImageClick,
|
|
52
170
|
};
|
|
53
171
|
},
|
|
54
172
|
},
|
|
55
173
|
mounted() {
|
|
56
174
|
this.width = this.$el.clientWidth;
|
|
57
175
|
this.height = this.$el.clientHeight;
|
|
176
|
+
this.windowWidth = window.innerWidth;
|
|
177
|
+
this.windowHeight = window.innerHeight;
|
|
178
|
+
this.$nextTick(() => {
|
|
179
|
+
this.defaultWidth = this.$refs.sameLayer.$el.clientWidth;
|
|
180
|
+
this.defaultHeight = this.$refs.sameLayer.$el.clientHeight;
|
|
181
|
+
this.defaultPosition =
|
|
182
|
+
this.$refs.sameLayer.$el.style.position || 'static';
|
|
183
|
+
});
|
|
58
184
|
},
|
|
59
|
-
|
|
60
185
|
methods: {
|
|
186
|
+
onFullscreenChange(isFullScreeen) {
|
|
187
|
+
if (isFullScreeen.flag) {
|
|
188
|
+
this.embedPosition = 'fixed';
|
|
189
|
+
this.embedHeight = this.windowWidth;
|
|
190
|
+
this.embedWidth = this.windowHeight;
|
|
191
|
+
} else {
|
|
192
|
+
this.embedPosition = this.defaultPosition;
|
|
193
|
+
this.embedHeight = this.defaultHeight;
|
|
194
|
+
this.embedWidth = this.defaultWidth;
|
|
195
|
+
}
|
|
196
|
+
},
|
|
61
197
|
// 自定义拓展其它逻辑
|
|
62
198
|
onProgress(res) {
|
|
63
|
-
|
|
64
|
-
this.$emit("onProgress", res);
|
|
199
|
+
this.$emit('onProgress', res);
|
|
65
200
|
},
|
|
66
201
|
|
|
67
202
|
onStart(res) {
|
|
68
|
-
|
|
69
|
-
this.$emit("onStart", res);
|
|
203
|
+
this.$emit('onStart', res);
|
|
70
204
|
},
|
|
71
205
|
|
|
72
206
|
onPause(res) {
|
|
73
|
-
|
|
74
|
-
this.$emit("onPause", res);
|
|
207
|
+
this.$emit('onPause', res);
|
|
75
208
|
},
|
|
76
209
|
|
|
77
210
|
finish(res) {
|
|
78
|
-
|
|
79
|
-
this.$emit("finish", res);
|
|
211
|
+
this.$emit('finish', res);
|
|
80
212
|
},
|
|
81
213
|
|
|
82
214
|
onFail(res) {
|
|
83
|
-
|
|
84
|
-
this.$emit("onFail", res);
|
|
215
|
+
this.$emit('onFail', res);
|
|
85
216
|
},
|
|
86
217
|
|
|
87
218
|
onReadyToPlay(res) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
219
|
+
this.$emit('onReadyToPlay', res);
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
deleteVideo(res) {
|
|
223
|
+
this.$emit('deleteVideo', res);
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
onDownloadSuccess(res) {
|
|
227
|
+
this.$emit('onDownloadSuccess', res);
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
onStartDownload(res) {
|
|
231
|
+
this.$emit('onStartDownload', res);
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
onPreviewImageClick(res) {
|
|
235
|
+
this.$emit('onPreviewImageClick', res);
|
|
236
|
+
},
|
|
91
237
|
},
|
|
92
238
|
};
|
|
93
|
-
</script>
|
|
239
|
+
</script>
|
package/src/transform-loader.js
CHANGED
|
@@ -21,9 +21,9 @@ const baseUrl = '../src/components/'
|
|
|
21
21
|
const componentMap = require("./index")
|
|
22
22
|
|
|
23
23
|
const componentSet = new Set()
|
|
24
|
-
const vBindMap = new Map()
|
|
25
24
|
// v-for 场景下,将 v-bind 转为方法调用所需的方法映射
|
|
26
25
|
const vBindMethodMap = new Map()
|
|
26
|
+
let vBindMethodCounter = 0
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* 判断是否为windows环境
|
|
@@ -69,7 +69,7 @@ function hasTargetElement(tagName) {
|
|
|
69
69
|
* 遍历html节点,将需要引入的组件添加到componentSet中
|
|
70
70
|
* @param {*} node html节点
|
|
71
71
|
*/
|
|
72
|
-
function traverseNode(node, parent = null) {
|
|
72
|
+
function traverseNode(node, parent = null, parentVForContext = false) {
|
|
73
73
|
if (node.type === 'element') {
|
|
74
74
|
const { hasElement, componentName } = hasTargetElement(node.tagName);
|
|
75
75
|
if (hasElement) {
|
|
@@ -77,23 +77,22 @@ function traverseNode(node, parent = null) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// 判断当前或父节点是否处于 v-for 场景
|
|
80
|
-
const hasVForInParent = parent && parent.attributes && parent.attributes.some(attr => attr.key === 'v-for')
|
|
81
80
|
const hasVForInCurrent = node.attributes && node.attributes.some(attr => attr.key === 'v-for')
|
|
82
|
-
const isInsideVFor =
|
|
81
|
+
const isInsideVFor = parentVForContext || hasVForInCurrent
|
|
83
82
|
|
|
84
83
|
if (node.attributes) {
|
|
85
84
|
node.attributes.forEach((attr, index) => {
|
|
86
85
|
if (attr.key === 'v-bind') {
|
|
87
86
|
if (isInsideVFor) {
|
|
88
87
|
// v-for 场景:将 v-bind="expr" 转为 v-bind="customVBindMethodX(expr)"
|
|
89
|
-
const methodName = `customVBindMethod${
|
|
90
|
-
const argExpression = (attr.value || '').trim() || '
|
|
88
|
+
const methodName = `customVBindMethod${vBindMethodCounter++}`;
|
|
89
|
+
const argExpression = (attr.value || '').trim() || 'undefined';
|
|
91
90
|
const paramName = 'arg';
|
|
92
91
|
if (!vBindMethodMap.has(methodName)) {
|
|
93
92
|
vBindMethodMap.set(methodName, { paramName });
|
|
94
93
|
}
|
|
95
94
|
// 更新模板中的属性为方法调用
|
|
96
|
-
node.attributes[index].value =
|
|
95
|
+
node.attributes[index].value = `{...${methodName}(${argExpression})}`;
|
|
97
96
|
} else {
|
|
98
97
|
if (
|
|
99
98
|
attr.value.trim().startsWith('{') &&
|
|
@@ -120,13 +119,13 @@ function traverseNode(node, parent = null) {
|
|
|
120
119
|
value: generator(parsedAst).code,
|
|
121
120
|
};
|
|
122
121
|
} else {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
node.attributes[index].value =
|
|
122
|
+
const methodName = `customVBindMethod${vBindMethodCounter++}`;
|
|
123
|
+
const argExpression = (attr.value || '').trim() || 'undefined';
|
|
124
|
+
const paramName = 'arg';
|
|
125
|
+
if (!vBindMethodMap.has(methodName)) {
|
|
126
|
+
vBindMethodMap.set(methodName, { paramName });
|
|
127
|
+
}
|
|
128
|
+
node.attributes[index].value = `{...${methodName}(${argExpression})}`;
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
}
|
|
@@ -136,7 +135,7 @@ function traverseNode(node, parent = null) {
|
|
|
136
135
|
// 继续递归处理子节点
|
|
137
136
|
if (node.children) {
|
|
138
137
|
node.children.forEach((child) => {
|
|
139
|
-
traverseNode(child, node); // 将当前节点作为 parent 传递给子节点
|
|
138
|
+
traverseNode(child, node, isInsideVFor); // 将当前节点作为 parent 传递给子节点
|
|
140
139
|
});
|
|
141
140
|
}
|
|
142
141
|
}
|
|
@@ -191,80 +190,6 @@ function getComponentLoc(name) {
|
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
192
|
//解决v-bind传的是 a.b.c这种 可能a是空导致报错
|
|
194
|
-
function createComputedProperty(vBindValue, computedName) {
|
|
195
|
-
// 使用辅助函数创建成员表达式,支持嵌套属性路径
|
|
196
|
-
const valueExpression = createMemberExpressionFromPath(vBindValue);
|
|
197
|
-
const styleExpression = t.memberExpression(createMemberExpressionFromPath(vBindValue), t.identifier('style'));
|
|
198
|
-
|
|
199
|
-
// 为嵌套路径创建逐级空值检查(如 a.b.c 需要检查 a && a.b && a.b.c)
|
|
200
|
-
const parts = vBindValue.split('.');
|
|
201
|
-
const nullCheckConditions = [];
|
|
202
|
-
for (let i = 0; i < parts.length; i++) {
|
|
203
|
-
nullCheckConditions.push(createMemberExpressionFromPath(parts.slice(0, i + 1).join('.')));
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// 构建逐级 && 检查表达式
|
|
207
|
-
let nullCheckExpression = nullCheckConditions[0];
|
|
208
|
-
for (let i = 1; i < nullCheckConditions.length; i++) {
|
|
209
|
-
nullCheckExpression = t.logicalExpression('&&', nullCheckExpression, nullCheckConditions[i]);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return t.objectProperty(
|
|
213
|
-
t.identifier('computed'), // 为对象添加 computed 属性
|
|
214
|
-
t.objectExpression([ // 计算属性
|
|
215
|
-
t.objectProperty(
|
|
216
|
-
t.identifier(computedName), // 计算属性的名称
|
|
217
|
-
t.functionExpression( // 计算属性的值是一个函数
|
|
218
|
-
null, //不需要传参
|
|
219
|
-
[],
|
|
220
|
-
t.blockStatement([ // 函数体是一个块语句,包含多个语句
|
|
221
|
-
// 先判断对象本身是否存在(逐级检查),不存在直接返回空对象
|
|
222
|
-
t.ifStatement(
|
|
223
|
-
t.unaryExpression('!', nullCheckExpression),
|
|
224
|
-
t.blockStatement([
|
|
225
|
-
t.returnStatement(t.objectExpression([]))
|
|
226
|
-
])
|
|
227
|
-
),
|
|
228
|
-
t.ifStatement(// if (this.xxx && this.xxx.style)
|
|
229
|
-
t.logicalExpression(
|
|
230
|
-
'&&', // 使用逻辑"与"操作符
|
|
231
|
-
valueExpression,
|
|
232
|
-
styleExpression
|
|
233
|
-
),
|
|
234
|
-
t.blockStatement([ // 如果条件符合
|
|
235
|
-
t.expressionStatement(
|
|
236
|
-
t.assignmentExpression(
|
|
237
|
-
'=', // 赋值操作
|
|
238
|
-
styleExpression,
|
|
239
|
-
t.callExpression(
|
|
240
|
-
t.memberExpression(t.thisExpression(), t.identifier('_px2rem')), // this._px2rem 函数
|
|
241
|
-
[styleExpression]
|
|
242
|
-
)
|
|
243
|
-
)
|
|
244
|
-
)
|
|
245
|
-
]),
|
|
246
|
-
),
|
|
247
|
-
t.returnStatement( // 返回展开后的浅拷贝,确保引用变化以触发依赖更新
|
|
248
|
-
t.objectExpression([
|
|
249
|
-
t.spreadElement(
|
|
250
|
-
t.callExpression(
|
|
251
|
-
t.memberExpression(t.identifier('Object'), t.identifier('assign')),
|
|
252
|
-
[
|
|
253
|
-
t.objectExpression([]),
|
|
254
|
-
valueExpression
|
|
255
|
-
]
|
|
256
|
-
)
|
|
257
|
-
)
|
|
258
|
-
])
|
|
259
|
-
)
|
|
260
|
-
])
|
|
261
|
-
)
|
|
262
|
-
)
|
|
263
|
-
])
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
193
|
/**
|
|
269
194
|
* 根据引入的路径获取组件导入的路径
|
|
270
195
|
* @param {*} address
|
|
@@ -284,15 +209,6 @@ function getAbsPath(address){
|
|
|
284
209
|
* @param {*} propertyPath 属性路径字符串
|
|
285
210
|
* @returns AST 成员表达式节点
|
|
286
211
|
*/
|
|
287
|
-
function createMemberExpressionFromPath(propertyPath) {
|
|
288
|
-
const parts = propertyPath.split('.');
|
|
289
|
-
let expression = t.memberExpression(t.thisExpression(), t.identifier(parts[0]));
|
|
290
|
-
for (let i = 1; i < parts.length; i++) {
|
|
291
|
-
expression = t.memberExpression(expression, t.identifier(parts[i]));
|
|
292
|
-
}
|
|
293
|
-
return expression;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
212
|
/**
|
|
297
213
|
* 生产SFC代码
|
|
298
214
|
* @param {*} moduleResoveRet
|
|
@@ -348,47 +264,7 @@ function addComponentsProperty(data) {
|
|
|
348
264
|
})
|
|
349
265
|
}
|
|
350
266
|
}
|
|
351
|
-
|
|
352
|
-
vBindMap.forEach((obj,customComputedName) => {
|
|
353
|
-
const computedProperty = createComputedProperty(obj.computedName, customComputedName);
|
|
354
|
-
traverse(scriptAst, {
|
|
355
|
-
ObjectExpression(path) { //对象key value
|
|
356
|
-
const computedNode = path.node.properties.find(
|
|
357
|
-
(property) => property.key && property.key.name === 'computed'
|
|
358
|
-
);
|
|
359
|
-
if (computedNode) { // 如果找到了computed,检查是否已经存在该计算属性
|
|
360
|
-
const existingProperty = computedNode.value.properties.find(
|
|
361
|
-
(property) => property.key && property.key.name === customComputedName
|
|
362
|
-
);
|
|
363
|
-
|
|
364
|
-
if (!existingProperty) { // 如果没有相同名称的计算属性,插入新计算属性
|
|
365
|
-
computedNode.value.properties.push(computedProperty.value.properties[0]);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
// 判断computed是否存在
|
|
370
|
-
ExportDefaultDeclaration(path) {
|
|
371
|
-
if (t.isObjectExpression(path.node.declaration)) {
|
|
372
|
-
const properties = path.node.declaration.properties;
|
|
373
|
-
let computedPropertyNode = properties.find((item) => item.key.name === 'computed');
|
|
374
|
-
if (!computedPropertyNode) {//创建
|
|
375
|
-
computedPropertyNode = t.objectProperty(t.identifier('computed'), t.objectExpression([]));
|
|
376
|
-
properties.push(computedPropertyNode);
|
|
377
|
-
}
|
|
378
|
-
// 继续检查是否已存在相同名称的计算属性
|
|
379
|
-
const existingProperty = computedPropertyNode.value.properties.find(
|
|
380
|
-
(property) => property.key && property.key.name === customComputedName
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
if (!existingProperty) {
|
|
384
|
-
computedPropertyNode.value.properties.push(computedProperty.value.properties[0]);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
// v-for: 注入 v-bind 方法(接收循环项,px2rem,返回新对象)
|
|
267
|
+
// 将 v-bind 表达式转为方法调用(接收源数据,px2rem,返回新对象)
|
|
392
268
|
/**
|
|
393
269
|
* v-for 场景专用:将模板中的 v-bind="expr" 改写为 v-bind="method(expr)"
|
|
394
270
|
* - methodName: 注入到 methods 的方法名
|
|
@@ -403,6 +279,12 @@ function createVBindMethod(methodName, paramName) {
|
|
|
403
279
|
t.identifier(methodName),
|
|
404
280
|
[t.identifier(paramName)],
|
|
405
281
|
t.blockStatement([
|
|
282
|
+
t.ifStatement(
|
|
283
|
+
t.unaryExpression('!', t.identifier(paramName)),
|
|
284
|
+
t.blockStatement([
|
|
285
|
+
t.returnStatement(t.objectExpression([]))
|
|
286
|
+
])
|
|
287
|
+
),
|
|
406
288
|
t.ifStatement(
|
|
407
289
|
t.logicalExpression(
|
|
408
290
|
'&&',
|
|
@@ -550,13 +432,10 @@ module.exports = function (source) {
|
|
|
550
432
|
componentSet.clear()
|
|
551
433
|
}
|
|
552
434
|
|
|
553
|
-
if (vBindMap.size !== 0) {
|
|
554
|
-
addComputedPropertyToScript(scriptAst, vBindMap);
|
|
555
|
-
vBindMap.clear()
|
|
556
|
-
}
|
|
557
435
|
if (vBindMethodMap.size !== 0) {
|
|
558
436
|
addVBindMethodsToScript(scriptAst, vBindMethodMap)
|
|
559
437
|
vBindMethodMap.clear()
|
|
438
|
+
vBindMethodCounter = 0
|
|
560
439
|
}
|
|
561
440
|
|
|
562
441
|
const {
|