Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
305b8398
U
uni-app
项目概览
anyefeiyu
/
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,发现更多精彩内容 >>
提交
305b8398
编写于
9月 24, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
# Conflicts: # packages/uni-h5/dist/index.umd.min.js
上级
b3df5069
85d2f0b2
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
49 addition
and
14 deletion
+49
-14
build/manifest.js
build/manifest.js
+4
-0
packages/uni-h5/dist/index.css
packages/uni-h5/dist/index.css
+1
-1
packages/uni-template-compiler/__tests__/compiler-extra.spec.js
...es/uni-template-compiler/__tests__/compiler-extra.spec.js
+5
-0
packages/uni-template-compiler/lib/script/traverse/data/event.js
...s/uni-template-compiler/lib/script/traverse/data/event.js
+27
-5
packages/vue-cli-plugin-uni/lib/h5/compiler-options.js
packages/vue-cli-plugin-uni/lib/h5/compiler-options.js
+3
-2
src/platforms/h5/components/app/layout.vue
src/platforms/h5/components/app/layout.vue
+8
-5
src/platforms/h5/helpers/can-i-use.js
src/platforms/h5/helpers/can-i-use.js
+1
-1
未找到文件。
build/manifest.js
浏览文件 @
305b8398
...
...
@@ -55,6 +55,10 @@ const DEPS = {
createIntersectionObserver
:
[
[
'
/core/view/bridge/subscribe/api/request-component-observer.js
'
,
'
requestComponentObserver
'
],
[
'
/core/view/bridge/subscribe/api/request-component-observer.js
'
,
'
destroyComponentObserver
'
]
],
createMediaQueryObserver
:
[
[
'
/core/view/bridge/subscribe/api/request-media-query-observer.js
'
,
'
requestMediaQueryObserver
'
],
[
'
/core/view/bridge/subscribe/api/request-media-query-observer.js
'
,
'
destroyMediaQueryObserver
'
]
]
}
...
...
packages/uni-h5/dist/index.css
浏览文件 @
305b8398
此差异已折叠。
点击以展开。
packages/uni-template-compiler/__tests__/compiler-extra.spec.js
浏览文件 @
305b8398
...
...
@@ -337,6 +337,11 @@ describe('mp:compiler-extra', () => {
'
<block wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view><view data-event-opts="{{[[
\'
tap
\'
,[[
\'
e0
\'
,[
\'
$event
\'
]]]]]}}" data-event-params="{{({item})}}" bindtap="__e"></view></view></block>
'
,
'
with(this){if(!_isMounted){e0=function($event,item){var _temp=arguments[arguments.length-1].currentTarget.dataset,_temp2=_temp.eventParams||_temp["event-params"],item=_temp2.item;var _temp,_temp2;return $test.test(item,item.length,undefined)}}}
'
)
assertCodegen
(
'
<view v-for="(item,index) in list" :key="index"><view @click="event=>showEventInfo(event,item)"></view></view>
'
,
'
<block wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view><view data-event-opts="{{[[
\'
tap
\'
,[[
\'
e0
\'
,[
\'
$event
\'
]]]]]}}" data-event-params="{{({item})}}" bindtap="__e"></view></view></block>
'
,
'
with(this){if(!_isMounted){e0=(event,item,...args)=>{var _temp=args[args.length-1].currentTarget.dataset,_temp2=_temp.eventParams||_temp["event-params"],item=_temp2.item;var _temp,_temp2;return showEventInfo(event,item)}}}
'
)
})
it
(
'
generate class binding
'
,
()
=>
{
...
...
packages/uni-template-compiler/lib/script/traverse/data/event.js
浏览文件 @
305b8398
...
...
@@ -202,6 +202,10 @@ function parseEventByCallExpression (callExpr, methods) {
methods
.
push
(
t
.
arrayExpression
(
arrayExpression
))
}
function
isValuePath
(
path
)
{
return
path
.
key
!==
'
key
'
&&
path
.
key
!==
'
id
'
&&
(
path
.
key
!==
'
property
'
||
path
.
parent
.
computed
)
&&
!
(
path
.
key
===
'
value
'
&&
path
.
parentPath
.
parentPath
.
isObjectPattern
())
&&
!
(
path
.
key
===
'
left
'
&&
path
.
parentPath
.
parentPath
.
parentPath
.
isObjectPattern
())
}
function
parseEvent
(
keyPath
,
valuePath
,
state
,
isComponent
,
isNativeOn
=
false
,
tagName
,
ret
)
{
const
key
=
keyPath
.
node
let
type
=
key
.
value
||
key
.
name
||
''
...
...
@@ -268,18 +272,31 @@ function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false,
state
.
errors
.
add
(
`
${
tagName
}
组件
${
type
}
事件仅支持 @
${
type
}
="methodName" 方式绑定`
)
}
else
if
(
funcPath
.
isArrowFunctionExpression
())
{
// e=>count++
methods
.
push
(
addEventExpressionStatement
(
funcPath
,
state
,
isCustom
))
}
else
{
let
anonymous
=
true
// "click":function($event) {click1(item);click2(item);}
const
body
=
funcPath
.
node
.
body
&&
funcPath
.
node
.
body
.
body
if
(
body
&&
body
.
length
)
{
const
funcParams
=
funcPath
.
node
.
params
if
(
body
&&
body
.
length
&&
funcParams
&&
funcParams
.
length
===
1
)
{
const
exprStatements
=
body
.
filter
(
node
=>
{
return
t
.
isExpressionStatement
(
node
)
&&
t
.
isCallExpression
(
node
.
expression
)
})
if
(
exprStatements
.
length
===
body
.
length
)
{
const
paramPath
=
funcPath
.
get
(
'
params
'
)[
0
]
const
paramName
=
paramPath
.
node
.
name
if
(
paramName
!==
'
$event
'
)
{
funcPath
.
get
(
'
body
'
).
traverse
({
Identifier
(
path
)
{
const
node
=
path
.
node
const
binding
=
path
.
scope
.
getBinding
(
node
.
name
)
if
(
binding
&&
binding
.
identifier
===
paramPath
.
node
&&
isValuePath
(
path
))
{
path
.
replaceWith
(
t
.
identifier
(
'
$event
'
))
}
}
})
paramPath
.
replaceWith
(
t
.
identifier
(
'
$event
'
))
}
anonymous
=
false
exprStatements
.
forEach
(
exprStatement
=>
{
parseEventByCallExpression
(
exprStatement
.
expression
,
methods
)
...
...
@@ -335,7 +352,7 @@ function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false,
const
scope
=
path
.
scope
const
node
=
path
.
node
const
name
=
node
.
name
if
(
path
.
key
!==
'
key
'
&&
(
path
.
key
!==
'
property
'
||
path
.
parent
.
computed
)
&&
scope
&&
!
scope
.
hasOwnBinding
(
name
)
&&
scope
.
hasBinding
(
name
)
&&
!
params
.
includes
(
name
)
&&
name
!==
'
undefined
'
)
{
if
(
isValuePath
(
path
)
&&
scope
&&
!
scope
.
hasOwnBinding
(
name
)
&&
scope
.
hasBinding
(
name
)
&&
!
params
.
includes
(
name
)
&&
name
!==
'
undefined
'
)
{
params
.
push
(
name
)
}
}
...
...
@@ -344,10 +361,15 @@ function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false,
funcPath
.
node
.
params
.
push
(
t
.
identifier
(
name
))
})
if
(
params
.
length
)
{
let
argumentsName
=
'
arguments
'
if
(
funcPath
.
isArrowFunctionExpression
())
{
argumentsName
=
'
args
'
funcPath
.
node
.
params
.
push
(
t
.
restElement
(
t
.
identifier
(
argumentsName
)))
}
const
datasetUid
=
funcPath
.
scope
.
generateDeclaredUidIdentifier
().
name
const
paramsUid
=
funcPath
.
scope
.
generateDeclaredUidIdentifier
().
name
const
dataset
=
ATTR_DATA_EVENT_PARAMS
.
substring
(
5
)
const
code
=
`var
${
datasetUid
}
=
arguments[arguments
.length-1].currentTarget.dataset,
${
paramsUid
}
=
${
datasetUid
}
.
${
dataset
.
replace
(
/-
([
a-z
])
/
,
(
_
,
str
)
=>
str
.
toUpperCase
())}
||
${
datasetUid
}
['
${
dataset
}
'],
${
params
.
map
(
item
=>
`
${
item
}
=
${
paramsUid
}
.
${
item
}
`
).
join
(
'
,
'
)}
`
const
code
=
`var
${
datasetUid
}
=
${
argumentsName
}
[
${
argumentsName
}
.length-1].currentTarget.dataset,
${
paramsUid
}
=
${
datasetUid
}
.
${
dataset
.
replace
(
/-
([
a-z
])
/
,
(
_
,
str
)
=>
str
.
toUpperCase
())}
||
${
datasetUid
}
['
${
dataset
}
'],
${
params
.
map
(
item
=>
`
${
item
}
=
${
paramsUid
}
.
${
item
}
`
).
join
(
'
,
'
)}
`
funcPath
.
node
.
body
.
body
.
unshift
(
parser
.
parse
(
code
).
program
.
body
[
0
])
}
methods
.
push
(
addEventExpressionStatement
(
funcPath
,
state
,
isComponent
,
isNativeOn
))
...
...
packages/vue-cli-plugin-uni/lib/h5/compiler-options.js
浏览文件 @
305b8398
...
...
@@ -16,14 +16,15 @@ function isFunction (expr) {
function
processEvent
(
expr
,
filterModules
)
{
const
isMethodPath
=
simplePathRE
.
test
(
expr
)
expr
=
`(
${
expr
}
)`
if
(
isMethodPath
||
isFunction
(
expr
))
{
if
(
filterModules
.
find
(
name
=>
expr
.
indexOf
(
name
+
'
.
'
)
===
0
))
{
return
`
$event = $handleWxsEvent($event);
(
${
expr
}
)
($event, $getComponentDescriptor())
${
expr
}
($event, $getComponentDescriptor())
`
}
else
{
expr
=
`
(
${
expr
}
)
(...arguments)`
expr
=
`
${
expr
}
(...arguments)`
}
}
return
`
...
...
src/platforms/h5/components/app/layout.vue
浏览文件 @
305b8398
...
...
@@ -6,10 +6,12 @@
<uni-top-window
v-if=
"topWindow"
v-show=
"showTopWindow && topWindowMediaQuery"
ref=
"topWindow"
:style=
"topWindowStyle"
>
<div
class=
"uni-top-window"
>
<div
ref=
"topWindow"
class=
"uni-top-window"
:style=
"topWindowStyle"
>
<v-uni-top-window
ref=
"top"
@
hook:mounted=
"onTopWindowInit"
...
...
@@ -214,7 +216,7 @@ export default {
onTopWindowInit
()
{
// TODO page header
let
windowTopHeight
=
'
0px
'
if
(
this
.
topWindowStyle
&&
this
.
topWindowStyle
.
width
)
{
if
(
this
.
topWindowStyle
&&
this
.
topWindowStyle
.
height
)
{
windowTopHeight
=
this
.
$refs
.
topWindow
.
offsetHeight
+
'
px
'
}
else
{
windowTopHeight
=
this
.
$refs
.
top
.
$el
.
offsetHeight
+
'
px
'
...
...
@@ -273,6 +275,7 @@ export default {
left
:
0
;
right
:
0
;
top
:
0
;
z-index
:
998
;
z-index
:
998
;
overflow
:
hidden
;
}
</
style
>
src/platforms/h5/helpers/can-i-use.js
浏览文件 @
305b8398
function
cssSupports
(
css
)
{
return
window
.
CSS
&&
window
.
CSS
.
supports
&&
window
.
CSS
.
supports
(
css
)
return
window
.
CSS
&&
window
.
CSS
.
supports
&&
(
window
.
CSS
.
supports
(
css
)
||
window
.
CSS
.
supports
(
'
--a
'
,
0
)
)
}
export
default
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录