提交 d59687bc 编写于 作者: fxy060608's avatar fxy060608

fix(mp-baidu): support follow-swan, login, inline-payment-panel #2997

上级 67fc9575
......@@ -15,6 +15,12 @@ function assertCodegen (template, templateCode, renderCode = 'with(this){}', opt
}
describe('mp:compiler-mp-baidu', () => {
it('generate component', () => {
assertCodegen(
'<login @getphonenumber="getphonenumbers" @loaderror="loaderrors"></login>',
'<login data-event-opts=\"{{[[\'getphonenumber\',[[\'getphonenumbers\',[\'$event\']]]],[\'loaderror\',[[\'loaderrors\',[\'$event\']]]]]}}\" bindgetphonenumber=\"__e\" bindloaderror=\"__e\"></login>'
)
})
it('generate class', () => {
assertCodegen(
'<view class="a external-class c" :class="class1">hello world</view>',
......@@ -75,40 +81,35 @@ describe('mp:compiler-mp-baidu', () => {
assertCodegen(
'<my-component><template v-slot="{item}">{{item}}<template></my-component>',
'<my-component vue-id="551070e6-1" vue-slots="{{[\'default\']}}"><view>{{item}}</view></my-component>',
'with(this){}',
{
'with(this){}', {
scopedSlotsCompiler: 'auto'
}
)
assertCodegen(
'<my-component><template v-slot="{item}">{{getValue(item)}}<template></my-component>',
'<my-component scoped-slots-compiler="augmented" vue-id="551070e6-1" vue-slots="{{[\'default\']}}"><block><block s-if="{{$root.m0}}">{{$root.m1}}</block></block></my-component>',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default","item")):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default","item")):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}', {
scopedSlotsCompiler: 'auto'
}
)
assertCodegen(
'<my-component><template v-slot="item">{{getValue(item.text)}}<template></my-component>',
'<my-component scoped-slots-compiler="augmented" vue-id="551070e6-1" vue-slots="{{[\'default\']}}"><block><block s-if="{{$root.m0}}">{{$root.m1}}</block></block></my-component>',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default").text):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default").text):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}', {
scopedSlotsCompiler: 'auto'
}
)
assertCodegen(
'<view><slot :item="item"><slot></view>',
'<view><block s-if="{{$slots.default}}"><slot var-item="item"></slot></block><block s-else><slot></slot></block></view>',
'with(this){if($scope.data.scopedSlotsCompiler==="augmented"){$setScopedSlotsParams("default",{"item":item})}}',
{
'with(this){if($scope.data.scopedSlotsCompiler==="augmented"){$setScopedSlotsParams("default",{"item":item})}}', {
scopedSlotsCompiler: 'auto'
}
)
assertCodegen(
'<view><slot v-bind="object"><slot></view>',
'<view><block s-if="{{$slots.default}}"><slot></slot></block><block s-else><slot></slot></block></view>',
'with(this){if($scope.data.scopedSlotsCompiler==="augmented"){$setScopedSlotsParams("default",object)}}',
{
'with(this){if($scope.data.scopedSlotsCompiler==="augmented"){$setScopedSlotsParams("default",object)}}', {
scopedSlotsCompiler: 'auto'
}
)
......@@ -156,4 +157,4 @@ describe('mp:compiler-mp-baidu', () => {
'<text>{{"我是第一行3\\\\n 我的第二行2"+title}}</text>'
)
})
})
})
......@@ -272,7 +272,7 @@ describe('mp:compiler-mp-weixin', () => {
it('generate page-meta', () => {
assertCodegen( // TODO vue-id
'<view><page-meta/><view><button></button></view></view>',
'<page-meta vue-id="551070e6-1" bind:__l="__l"></page-meta><view><button></button></view>'
'<page-meta></page-meta><view><button></button></view>'
)
})
......
......@@ -53,6 +53,16 @@ const tags = {
'web-view',
'editor'
],
'mp-baidu': [
'follow-swan',
'login',
'inline-payment-panel'
],
'mp-weixin': [
'page-meta',
'navigation-bar',
'match-media'
],
// 支付宝小程序平台独有组件
'mp-alipay': [
'lifestyle',
......@@ -111,7 +121,9 @@ ${content}
return `${eventType}${eventName}` // 原生组件不支持 bind:input 等写法,统一使用 bindinput
},
createScopedSlots (slotName, props, state) {
state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { 0: `[${slotName}]` }))
state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', {
0: `[${slotName}]`
}))
return {
type: 'slot',
attr: {
......@@ -124,7 +136,9 @@ ${content}
traverseExpr,
normalizeChildren
}, state) {
state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { 0: `[${slotName}]` }))
state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', {
0: `[${slotName}]`
}))
return {
type: 'view',
attr: {
......@@ -146,4 +160,4 @@ module.exports = function getCompilerOptions (platform) {
baseCompiler,
require(id + '/lib/uni.compiler.js')
)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册