Closed
Description
Version
15.7.0
Reproduction link
https://codepen.io/Monine/pen/rELQZW
Steps to reproduce
视图会输出 render 属性值,打开开发者工具查看 console 面板也可以查看编译结果。
What is expected?
render 属性的值应该为:
"with(this){return _c('CustomerComp',{scopedSlots:_u([_l((['a']),function(name){return {key:name,fn:function(){return undefined},proxy:true}}),_l((['b']),function(name){return {key:name,fn:function(){return undefined},proxy:true}})],null,true)})}"
格式化后:
with (this) {
return _c('CustomerComp', {
scopedSlots: _u(
[
_l(['a'], function(name) {
return {
key: name,
fn: function() {
return undefined;
},
proxy: true,
};
}),
_l(['b'], function(name) {
return {
key: name,
fn: function() {
return undefined;
},
proxy: true,
};
}),
],
null,
true,
),
});
}
What is actually happening?
render 属性的值为:
"with(this){return _c('CustomerComp',{scopedSlots:_u([_l((['b']),function(name){return {key:name,fn:function(){return undefined},proxy:true}})],null,true)})}"
格式化后:
with (this) {
return _c('CustomerComp', {
scopedSlots: _u(
[
_l(['b'], function(name) {
return {
key: name,
fn: function() {
return undefined;
},
proxy: true,
};
}),
],
null,
true,
),
});
}
已经找到问题原因,在 vue-template-compiler build.js L2470-L2471,动态具名插槽名称 相同的情况下后者会替换前者。
此处我认为应该针对 动态具名插槽名称 进行判断,如果相同,则向名称添加额外唯一标识,防止被后者替换前者的情况出现。
Metadata
Metadata
Assignees
Labels
No labels