Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
d59687bc
U
uni-app
项目概览
小浣熊撸代码
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d59687bc
编写于
11月 16, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp-baidu): support follow-swan, login, inline-payment-panel #2997
上级
67fc9575
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
15 deletion
+30
-15
packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
...uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
+12
-11
packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
...ni-template-compiler/__tests__/compiler-mp-weixin.spec.js
+1
-1
packages/uni-template-compiler/lib/mp.js
packages/uni-template-compiler/lib/mp.js
+17
-3
未找到文件。
packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
浏览文件 @
d59687bc
...
...
@@ -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>
'
)
})
})
})
packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
浏览文件 @
d59687bc
...
...
@@ -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>
'
)
})
...
...
packages/uni-template-compiler/lib/mp.js
浏览文件 @
d59687bc
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录