Skip to content

Commit c1feaab

Browse files
committed
mpvue 2.0
1 parent f21ee4d commit c1feaab

File tree

3 files changed

+18
-36
lines changed

3 files changed

+18
-36
lines changed

packages/mpvue-template-compiler/build.js

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5895,9 +5895,9 @@ var attrs$3 = {
58955895
} else if (key === 'v-show') {
58965896
attrs['hidden'] = "{{!(" + val + ")}}";
58975897
} else if (/^v\-on\:/i.test(key)) {
5898-
attrs = this$1.event(key, val, attrs, tag);
5898+
attrs = this$1.event(key, val, attrs, tag, log);
58995899
} else if (/^v\-bind\:/i.test(key)) {
5900-
attrs = this$1.bind(key, val, attrs, tag, attrsMap['wx:key']);
5900+
attrs = this$1.bind(key, val, attrs, tag, attrsMap['a:key']);
59015901
} else if (/^v\-model/.test(key)) {
59025902
attrs = this$1.model(key, val, attrs, tag, log);
59035903
} else if (directiveMap$3[key]) {
@@ -5941,7 +5941,7 @@ var attrs$3 = {
59415941
return ast
59425942
},
59435943

5944-
event: function event (key, val, attrs, tag) {
5944+
event: function event (key, val, attrs, tag, log) {
59455945
// 小程序能力所致,bind 和 catch 事件同时绑定时候,只会触发 bind ,catch 不会被触发。
59465946
// .stop 的使用会阻止冒泡,但是同时绑定了一个非冒泡事件,会导致该元素上的 catchEventName 失效!
59475947
// .prevent 可以直接干掉,因为小程序里没有什么默认事件,比如submit并不会跳转页面
@@ -5968,7 +5968,7 @@ var attrs$3 = {
59685968
var eventType = 'on';
59695969
var isStop = eventNameMap.includes('stop');
59705970
if (eventNameMap.includes('capture')) {
5971-
eventType = isStop ? 'capture-catch:' : 'capture-bind:';
5971+
log('支付宝小程序不支持事件捕获');
59725972
} else if (isStop) {
59735973
eventType = 'catch';
59745974
}
@@ -5983,28 +5983,12 @@ var attrs$3 = {
59835983
var name = key.replace(/^v\-bind\:/i, '');
59845984

59855985
if (isIf && name === 'key') {
5986-
attrs['wx:key'] = val;
5986+
attrs['a:key'] = val;
59875987
}
59885988

5989-
node.tag = 'template';
5990-
node.attrsMap.name = slotId;
5991-
delete node.attrsMap.slot;
5992-
// 缓存,会集中生成一个 slots 文件
5993-
slots[slotId] = { node: convertAst$1(node, options, util), name: slotName, slotId: slotId };
5994-
wxmlAst.slots[slotName] = slotId;
5995-
});
5996-
// 清理当前组件下的节点信息,因为 slot 都被转移了
5997-
children.length = 0;
5998-
wxmlAst.children.length = 0;
5999-
}
6000-
6001-
wxmlAst.attrsMap = attrs$1.format(wxmlAst.attrsMap);
6002-
wxmlAst = tag$1(wxmlAst, options);
6003-
wxmlAst = convertFor$1(wxmlAst, options);
6004-
wxmlAst = attrs$1.convertAttr(wxmlAst, log);
6005-
if (children && !isSlot) {
6006-
wxmlAst.children = children.map(function (k) { return convertAst$1(k, options, util); });
6007-
}
5989+
if (tag === 'template') {
5990+
return attrs
5991+
}
60085992

60095993
if (name === 'href') {
60105994
attrs['url'] = "{{" + val + "}}";
@@ -6046,18 +6030,17 @@ var attrs$3 = {
60466030
attrs['value'] = "{{" + val + "}}";
60476031
if (key === 'v-model.lazy') {
60486032
if (isFormInput) {
6049-
attrs['bindblur'] = 'handleProxy';
6033+
attrs['onBlur'] = 'handleProxy';
60506034
} else {
6051-
attrs['bindchange'] = 'handleProxy';
6035+
attrs['onChange'] = 'handleProxy';
60526036
}
60536037
} else {
60546038
if (isFormInput) {
6055-
attrs['bindinput'] = 'handleProxy';
6039+
attrs['onInput'] = 'handleProxy';
60566040
} else {
6057-
attrs['bindchange'] = 'handleProxy';
6041+
attrs['onChange'] = 'handleProxy';
60586042
}
60596043
}
6060-
60616044
return attrs
60626045
}
60636046
};
@@ -6146,9 +6129,11 @@ var convertFor$3 = function (ast) {
61466129
attrsMap[astMap$3['alias']] = alias;
61476130
}
61486131

6149-
// 引用子模版
6150-
var importCode = Object.keys(deps).map(function (k) { return components[k] ? ("<import src=\"" + (components[k].src) + "\" />") : ''; }).join('');
6151-
code = importCode + "<template name=\"" + (options.name) + "\">" + code + "</template>";
6132+
delete attrsMap['v-for'];
6133+
}
6134+
6135+
return ast
6136+
};
61526137

61536138
function mpmlAst$3 (compiled, options, log) {
61546139
if ( options === void 0 ) options = {};

packages/mpvue-template-compiler/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "mpvue-template-compiler",
33
"version": "2.0.0",
4-
"version": "1.0.20",
54
"description": "mpvue template compiler for Vue",
65
"main": "index.js",
76
"repository": {
@@ -26,4 +25,3 @@
2625
"de-indent": "^1.0.2"
2726
}
2827
}
29-

packages/mpvue/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4185,7 +4185,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
41854185
});
41864186

41874187
Vue$3.version = '2.4.1';
4188-
Vue$3.mpvueVersion = '1.0.20';
4188+
Vue$3.mpvueVersion = '2.0.0';
41894189

41904190
/* globals renderer */
41914191

@@ -5471,7 +5471,6 @@ function diffData (vm, data) {
54715471
Object.keys(vmData).forEach(function (vmDataItemKey) {
54725472
if (vmData[vmDataItemKey] instanceof Object) {
54735473
// 引用类型
5474-
if (vmDataItemKey === '__keyPath') { return }
54755474
minifyDeepData(rootKey, vmDataItemKey, vmData[vmDataItemKey], data, vm._mpValueSet, vm);
54765475
} else if (vmData[vmDataItemKey] !== undefined) {
54775476
// _data上的值属性只有要更新的时候才赋值

0 commit comments

Comments
 (0)