Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
ed9bde93
U
uni-app
项目概览
MuGuiLin
/
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,发现更多精彩内容 >>
提交
ed9bde93
编写于
6月 24, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp-baidu): Make sure the event is up to date (#3647)
上级
6a05ddc1
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
42 addition
and
20 deletion
+42
-20
packages/uni-cli-shared/src/vue/transforms/index.ts
packages/uni-cli-shared/src/vue/transforms/index.ts
+1
-0
packages/uni-cli-shared/src/vue/transforms/vModel.ts
packages/uni-cli-shared/src/vue/transforms/vModel.ts
+2
-1
packages/uni-cli-shared/src/vue/transforms/vOn.ts
packages/uni-cli-shared/src/vue/transforms/vOn.ts
+19
-9
packages/uni-mp-baidu/__tests__/vModel.spec.ts
packages/uni-mp-baidu/__tests__/vModel.spec.ts
+2
-2
packages/uni-mp-baidu/__tests__/vOn.spec.ts
packages/uni-mp-baidu/__tests__/vOn.spec.ts
+2
-2
packages/uni-mp-compiler/src/runtimeHelpers.ts
packages/uni-mp-compiler/src/runtimeHelpers.ts
+3
-1
packages/uni-mp-core/src/runtime/util.ts
packages/uni-mp-core/src/runtime/util.ts
+7
-1
packages/uni-mp-kuaishou/__tests__/vModel.spec.ts
packages/uni-mp-kuaishou/__tests__/vModel.spec.ts
+2
-2
packages/uni-mp-kuaishou/__tests__/vOn.spec.ts
packages/uni-mp-kuaishou/__tests__/vOn.spec.ts
+2
-2
packages/uni-mp-vue/src/helpers/index.ts
packages/uni-mp-vue/src/helpers/index.ts
+2
-0
未找到文件。
packages/uni-cli-shared/src/vue/transforms/index.ts
浏览文件 @
ed9bde93
...
...
@@ -12,6 +12,7 @@ export * from './transformTag'
export
{
createAssetUrlTransformWithOptions
}
from
'
./templateTransformAssetUrl
'
export
{
createSrcsetTransformWithOptions
}
from
'
./templateTransformSrcset
'
export
{
STRINGIFY_JSON
,
ATTR_DATASET_EVENT_OPTS
,
createTransformOn
,
defaultMatch
as
matchTransformOn
,
...
...
packages/uni-cli-shared/src/vue/transforms/vModel.ts
浏览文件 @
ed9bde93
...
...
@@ -38,7 +38,8 @@ export function createTransformModel(
addEventOpts
(
(
arg
as
SimpleExpressionNode
).
content
,
exp
as
SimpleExpressionNode
,
node
as
ComponentNode
node
as
ComponentNode
,
context
)
props
[
1
].
exp
=
createCustomEventExpr
()
}
...
...
packages/uni-cli-shared/src/vue/transforms/vOn.ts
浏览文件 @
ed9bde93
...
...
@@ -52,7 +52,8 @@ export function createTransformOn(
?
customizeEvent
(
arg
.
content
)
:
arg
.
content
,
value
,
node
node
,
context
)
return
res
}
...
...
@@ -65,7 +66,8 @@ export function createCustomEventExpr() {
export
function
addEventOpts
(
event
:
string
,
value
:
ExpressionNode
,
node
:
ElementNode
node
:
ElementNode
,
context
:
TransformContext
)
{
const
attrName
=
node
.
tagType
===
ElementTypes
.
COMPONENT
...
...
@@ -73,7 +75,7 @@ export function addEventOpts(
:
ATTR_DATASET_EVENT_OPTS
const
opts
=
findProp
(
node
,
attrName
,
true
)
as
DirectiveNode
if
(
!
opts
)
{
node
.
props
.
push
(
createDataEventOptsProp
(
attrName
,
event
,
value
))
node
.
props
.
push
(
createDataEventOptsProp
(
attrName
,
event
,
value
,
context
))
}
else
{
const
children
=
(
opts
.
exp
as
CompoundExpressionNode
).
children
children
.
splice
(
...
...
@@ -91,22 +93,30 @@ function createDataEventOptsProperty(event: string, exp: ExpressionNode) {
return
createCompoundExpression
([
`'
${
event
}
'`
,
'
:
'
,
exp
,
'
,
'
])
}
export
const
STRINGIFY_JSON
=
Symbol
(
`stringifyJson`
)
function
createDataEventOptsProp
(
name
:
string
,
event
:
string
,
exp
:
ExpressionNode
exp
:
ExpressionNode
,
context
:
TransformContext
):
DirectiveNode
{
const
children
=
[]
const
stringify
=
name
===
ATTR_DATA_EVENT_OPTS
if
(
stringify
)
{
children
.
push
(
context
.
helperString
(
STRINGIFY_JSON
)
+
'
(
'
)
}
children
.
push
(
'
{
'
,
createDataEventOptsProperty
(
event
,
exp
),
'
}
'
)
if
(
stringify
)
{
children
.
push
(
'
)
'
)
}
return
{
type
:
NodeTypes
.
DIRECTIVE
,
name
:
'
bind
'
,
loc
:
locStub
,
modifiers
:
[],
arg
:
createSimpleExpression
(
name
,
true
),
exp
:
createCompoundExpression
([
'
{
'
,
createDataEventOptsProperty
(
event
,
exp
),
'
}
'
,
]),
exp
:
createCompoundExpression
(
children
),
}
}
...
...
packages/uni-mp-baidu/__tests__/vModel.spec.ts
浏览文件 @
ed9bde93
...
...
@@ -6,7 +6,7 @@ describe('mp-baidu: transform v-model', () => {
`<Comp v-model="model" />`
,
`<comp s-if="{{b}}" u-i="2a9ec0b0-0" eO="{{a}}" bindupdateModelValue="__e" u-p="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a:
{ 'updateModelValue': _o($event => _ctx.model = $event) }
, b: _p({ modelValue: _ctx.model }) }
return { a:
_j({ 'updateModelValue': _o($event => _ctx.model = $event) })
, b: _p({ modelValue: _ctx.model }) }
}`
)
})
...
...
@@ -15,7 +15,7 @@ describe('mp-baidu: transform v-model', () => {
`<Comp v-model="model" />`
,
`<comp s-if="{{b}}" u-i="2a9ec0b0-0" eO="{{a}}" bindupdateModelValue="__e" u-p="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a:
{ 'updateModelValue': _o($event => _ctx.model = $event) }
, b: _p({ modelValue: _ctx.model }) }
return { a:
_j({ 'updateModelValue': _o($event => _ctx.model = $event) })
, b: _p({ modelValue: _ctx.model }) }
}`
,
{
cacheHandlers
:
true
,
...
...
packages/uni-mp-baidu/__tests__/vOn.spec.ts
浏览文件 @
ed9bde93
...
...
@@ -16,7 +16,7 @@ describe('mp-baidu: transform v-on', () => {
`<custom @click="click"/>`
,
`<custom bindclick="__e" u-i="2a9ec0b0-0" eO="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a:
{ 'click': _o(_ctx.click) }
}
return { a:
_j({ 'click': _o(_ctx.click) })
}
}`
)
}),
...
...
@@ -25,7 +25,7 @@ describe('mp-baidu: transform v-on', () => {
`<custom @unmount="unmount" @update:modelValue="changeHandle" @custom-mount="mount();created();"/>`
,
`<custom bindunmount="__e" bindupdateModelValue="__e" bindcustomMount="__e" u-i="2a9ec0b0-0" eO="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a:
{ 'updateModelValue': _o(_ctx.changeHandle), 'customMount': _o($event => { _ctx.mount(); _ctx.created(); }), 'unmount': _o(_ctx.unmount) }
}
return { a:
_j({ 'unmount': _o(_ctx.unmount), 'updateModelValue': _o(_ctx.changeHandle), 'customMount': _o($event => { _ctx.mount(); _ctx.created(); }) })
}
}`
)
})
...
...
packages/uni-mp-compiler/src/runtimeHelpers.ts
浏览文件 @
ed9bde93
import
{
registerRuntimeHelpers
}
from
'
@vue/compiler-core
'
import
{
STRINGIFY_JSON
}
from
'
@dcloudio/uni-cli-shared
'
export
const
V_ON
=
Symbol
(
`vOn`
)
export
const
V_FOR
=
Symbol
(
`vFor`
)
export
const
EXTEND
=
Symbol
(
`extend`
)
...
...
@@ -14,6 +14,7 @@ export const STRINGIFY_STYLE = Symbol(`stringifyStyle`)
export
const
NORMALIZE_CLASS
=
Symbol
(
`normalizeClass`
)
export
const
TO_DISPLAY_STRING
=
Symbol
(
`toDisplayString`
)
export
const
WITH_MODEL_MODIFIERS
=
Symbol
(
`withModelModifiers`
)
registerRuntimeHelpers
({
[
V_ON
]:
'
o
'
,
[
V_FOR
]:
'
f
'
,
...
...
@@ -29,4 +30,5 @@ registerRuntimeHelpers({
[
NORMALIZE_CLASS
]:
'
n
'
,
[
TO_DISPLAY_STRING
]:
'
t
'
,
[
WITH_MODEL_MODIFIERS
]:
'
m
'
,
[
STRINGIFY_JSON
]:
'
j
'
,
})
packages/uni-mp-core/src/runtime/util.ts
浏览文件 @
ed9bde93
...
...
@@ -142,7 +142,13 @@ export function handleEvent(
// 快手小程序的 __l 方法也会走此处逻辑,但没有 __ins__
if
(
__ins__
)
{
// 自定义事件,通过 triggerEvent 传递 __ins__
methodName
=
resolveMethodName
(
type
,
__ins__
.
properties
[
EVENT_OPTS
]
||
{})
let
eventObj
=
{}
try
{
// https://github.com/dcloudio/uni-app/issues/3647
// 通过字符串序列化解决百度小程序修改对象不触发组件properties变化的Bug
eventObj
=
JSON
.
parse
(
__ins__
.
properties
[
EVENT_OPTS
])
}
catch
(
e
)
{}
methodName
=
resolveMethodName
(
type
,
eventObj
)
}
else
if
(
dataset
&&
dataset
[
EVENT_OPTS
])
{
// 快手小程序 input 等内置组件的 input 事件也会走此逻辑,所以从 dataset 中读取
methodName
=
resolveMethodName
(
type
,
dataset
[
EVENT_OPTS
])
...
...
packages/uni-mp-kuaishou/__tests__/vModel.spec.ts
浏览文件 @
ed9bde93
...
...
@@ -6,7 +6,7 @@ describe('mp-kuaishou: transform v-model', () => {
`<Comp v-model="model" />`
,
`<comp ks:if="{{b}}" u-i="2a9ec0b0-0" bind:__l="__l" eO="{{a}}" bindupdateModelValue="__e" u-p="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a:
{ 'updateModelValue': _o($event => _ctx.model = $event) }
, b: _p({ modelValue: _ctx.model }) }
return { a:
_j({ 'updateModelValue': _o($event => _ctx.model = $event) })
, b: _p({ modelValue: _ctx.model }) }
}`
)
})
...
...
@@ -15,7 +15,7 @@ describe('mp-kuaishou: transform v-model', () => {
`<Comp v-model="model" />`
,
`<comp ks:if="{{b}}" u-i="2a9ec0b0-0" bind:__l="__l" eO="{{a}}" bindupdateModelValue="__e" u-p="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a:
{ 'updateModelValue': _o($event => _ctx.model = $event) }
, b: _p({ modelValue: _ctx.model }) }
return { a:
_j({ 'updateModelValue': _o($event => _ctx.model = $event) })
, b: _p({ modelValue: _ctx.model }) }
}`
,
{
cacheHandlers
:
true
,
...
...
packages/uni-mp-kuaishou/__tests__/vOn.spec.ts
浏览文件 @
ed9bde93
...
...
@@ -36,7 +36,7 @@ describe('mp-kuaishou: transform v-on', () => {
`<custom @click="click"/>`
,
`<custom bindclick="__e" u-i="2a9ec0b0-0" bind:__l="__l" eO="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a:
{ 'click': _o(_ctx.click) }
}
return { a:
_j({ 'click': _o(_ctx.click) })
}
}`
)
}),
...
...
@@ -45,7 +45,7 @@ describe('mp-kuaishou: transform v-on', () => {
`<custom @unmount="unmount" @custom-mount="mount();created();"/>`
,
`<custom bindunmount="__e" bindcustomMount="__e" u-i="2a9ec0b0-0" bind:__l="__l" eO="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a:
{ 'customMount': _o($event => { _ctx.mount(); _ctx.created(); }), 'unmount': _o(_ctx.unmount) }
}
return { a:
_j({ 'unmount': _o(_ctx.unmount), 'customMount': _o($event => { _ctx.mount(); _ctx.created(); }) })
}
}`
)
})
...
...
packages/uni-mp-vue/src/helpers/index.ts
浏览文件 @
ed9bde93
...
...
@@ -44,3 +44,5 @@ export const m: typeof withModelModifiers = (
modifiers
,
isComponent
=
false
)
=>
withModelModifiers
(
fn
,
modifiers
,
isComponent
)
export
const
j
=
(
obj
:
unknown
)
=>
JSON
.
stringify
(
obj
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录