Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touchx
uni-app
提交
b099924f
U
uni-app
项目概览
touchx
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b099924f
编写于
1月 02, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://github.com/dcloudio/uni-app
into alpha
上级
ad97c98a
9f13c0fd
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
98 addition
and
22 deletion
+98
-22
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+24
-2
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
...ompiler/__tests__/compiler-app-plus-extra.service.spec.js
+12
-4
packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
...late-compiler/__tests__/compiler-app-plus.service.spec.js
+1
-1
packages/uni-template-compiler/__tests__/demo.js
packages/uni-template-compiler/__tests__/demo.js
+4
-4
packages/uni-template-compiler/lib/app/parser/base-parser.js
packages/uni-template-compiler/lib/app/parser/base-parser.js
+7
-2
packages/uni-template-compiler/lib/app/service.js
packages/uni-template-compiler/lib/app/service.js
+15
-1
packages/uni-template-compiler/lib/app/util.js
packages/uni-template-compiler/lib/app/util.js
+8
-4
src/platforms/app-plus/service/bridge.js
src/platforms/app-plus/service/bridge.js
+1
-1
src/platforms/app-plus/service/framework/plugins/data.js
src/platforms/app-plus/service/framework/plugins/data.js
+19
-0
src/platforms/h5/components/system-routes/open-location/index.vue
...forms/h5/components/system-routes/open-location/index.vue
+1
-1
src/shared/util.js
src/shared/util.js
+6
-2
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
b099924f
...
@@ -250,6 +250,10 @@ var serviceContext = (function () {
...
@@ -250,6 +250,10 @@ var serviceContext = (function () {
return
typeof
fn
===
'
function
'
return
typeof
fn
===
'
function
'
}
}
function
isObject
(
obj
)
{
return
obj
!==
null
&&
typeof
obj
===
'
object
'
}
function
isPlainObject
(
obj
)
{
function
isPlainObject
(
obj
)
{
return
_toString
.
call
(
obj
)
===
'
[object Object]
'
return
_toString
.
call
(
obj
)
===
'
[object Object]
'
}
}
...
@@ -258,7 +262,7 @@ var serviceContext = (function () {
...
@@ -258,7 +262,7 @@ var serviceContext = (function () {
return
hasOwnProperty
.
call
(
obj
,
key
)
return
hasOwnProperty
.
call
(
obj
,
key
)
}
}
function
noop
()
{
}
function
noop
()
{}
function
toRawType
(
val
)
{
function
toRawType
(
val
)
{
return
_toString
.
call
(
val
).
slice
(
8
,
-
1
)
return
_toString
.
call
(
val
).
slice
(
8
,
-
1
)
...
@@ -2718,7 +2722,7 @@ var serviceContext = (function () {
...
@@ -2718,7 +2722,7 @@ var serviceContext = (function () {
}
}
return
page
.
$page
.
meta
.
isTabBar
return
page
.
$page
.
meta
.
isTabBar
}
}
const
route
=
__uniRoutes
.
find
(
route
=>
route
.
path
.
slice
(
1
)
===
path
);
const
route
=
__uniRoutes
.
find
(
route
=>
route
.
path
.
replace
(
/^
\/
/
,
''
)
===
path
.
replace
(
/^
\/
/
,
''
)
);
return
route
&&
route
.
meta
.
isTabBar
return
route
&&
route
.
meta
.
isTabBar
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
...
@@ -12760,11 +12764,29 @@ var serviceContext = (function () {
...
@@ -12760,11 +12764,29 @@ var serviceContext = (function () {
return
((
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{}))[
name
]
=
value
)
return
((
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{}))[
name
]
=
value
)
}
}
function
fillVForData
(
forItems
,
vForData
)
{
let
i
,
l
;
if
(
Array
.
isArray
(
forItems
)
||
typeof
forItems
===
'
string
'
)
{
for
(
i
=
0
,
l
=
forItems
.
length
;
i
<
l
;
i
++
)
{
vForData
[
i
]
=
i
;
}
}
else
if
(
typeof
forItems
===
'
number
'
)
{
for
(
i
=
0
;
i
<
forItems
;
i
++
)
{
vForData
[
i
]
=
i
;
}
}
else
if
(
isObject
(
forItems
))
{
for
(
i
=
0
,
l
=
Object
.
keys
(
forItems
).
length
;
i
<
l
;
i
++
)
{
vForData
[
i
]
=
i
;
}
}
}
function
setForData
(
id
,
value
)
{
function
setForData
(
id
,
value
)
{
const
diffData
=
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{});
const
diffData
=
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{});
const
vForData
=
diffData
[
V_FOR
]
||
(
diffData
[
V_FOR
]
=
[]);
const
vForData
=
diffData
[
V_FOR
]
||
(
diffData
[
V_FOR
]
=
[]);
if
(
value
.
forItems
)
{
if
(
value
.
forItems
)
{
value
.
fill
&&
fillVForData
(
value
.
forItems
,
vForData
);
return
value
.
forItems
return
value
.
forItems
}
}
...
...
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
浏览文件 @
b099924f
...
@@ -44,11 +44,11 @@ describe('codegen', () => {
...
@@ -44,11 +44,11 @@ describe('codegen', () => {
)
)
assertCodegen
(
assertCodegen
(
'
<div><template v-for="item in items">text</template></div>
'
,
'
<div><template v-for="item in items">text</template></div>
'
,
`with(this){return _c('div',[_l((_$s(1,'f',{forItems:items})),function(item,$10,$20,$30){return void 0})],2)}`
`with(this){return _c('div',[_l((_$s(1,'f',{forItems:items
,fill:true
})),function(item,$10,$20,$30){return void 0})],2)}`
)
)
assertCodegen
(
assertCodegen
(
'
<div><template v-for="item in items">{{text}}</template></div>
'
,
'
<div><template v-for="item in items">{{text}}</template></div>
'
,
`with(this){return _c('div',[_l((_$s(1,'f',{forItems:items})),function(item,$10,$20,$30){return [_v((_$s(("1-"+$30),'t0',_s(text))))]})],2)}`
`with(this){return _c('div',[_l((_$s(1,'f',{forItems:items
,fill:true
})),function(item,$10,$20,$30){return [_v((_$s(("1-"+$30),'t0',_s(text))))]})],2)}`
)
)
assertCodegen
(
assertCodegen
(
'
<div><template v-for="item in items"><span></span>{{text}}</template></div>
'
,
'
<div><template v-for="item in items"><span></span>{{text}}</template></div>
'
,
...
@@ -56,12 +56,20 @@ describe('codegen', () => {
...
@@ -56,12 +56,20 @@ describe('codegen', () => {
)
)
assertCodegen
(
assertCodegen
(
'
<div><template v-for="item in items">a {{text1}} b {{text2}}</template></div>
'
,
'
<div><template v-for="item in items">a {{text1}} b {{text2}}</template></div>
'
,
`with(this){return _c('div',[_l((_$s(1,'f',{forItems:items})),function(item,$10,$20,$30){return [_v((_$s(("1-"+$30),'t0',_s(text1)))+(_$s(("1-"+$30),'t1',_s(text2))))]})],2)}`
`with(this){return _c('div',[_l((_$s(1,'f',{forItems:items
,fill:true
})),function(item,$10,$20,$30){return [_v((_$s(("1-"+$30),'t0',_s(text1)))+(_$s(("1-"+$30),'t1',_s(text2))))]})],2)}`
)
)
assertCodegen
(
assertCodegen
(
'
<div><template v-for="item in items"><span v-if="item.sub"></span></template></div>
'
,
'
<div><template v-for="item in items"><span v-if="item.sub"></span></template></div>
'
,
`with(this){return _c('div',[_l((_$s(1,'f',{forItems:items})),function(item,$10,$20,$30){return [(_$s(("2-"+$30),'i',item.sub))?_c('span',{key:_$s(1,'f',{forIndex:$20,keyIndex:0,key:1+'-0'+$30})}):_e()]})],2)}`
`with(this){return _c('div',[_l((_$s(1,'f',{forItems:items})),function(item,$10,$20,$30){return [(_$s(("2-"+$30),'i',item.sub))?_c('span',{key:_$s(1,'f',{forIndex:$20,keyIndex:0,key:1+'-0'+$30})}):_e()]})],2)}`
)
)
assertCodegen
(
'
<view><template v-for="(item, index) in arr">{{item}}</template></view>
'
,
`with(this){return _c('view',[_l((_$s(1,'f',{forItems:arr,fill:true})),function(item,index,$20,$30){return [_v((_$s(("1-"+$30),'t0',_s(item))))]})],2)}`
)
assertCodegen
(
'
<view><block v-for="(item, index) in arr" v-bind:key="index">{{item}}</block></view>
'
,
`with(this){return _c('view',[_l((_$s(1,'f',{forItems:arr,fill:true})),function(item,index,$20,$30){return [_v((_$s(("1-"+$30),'t0',_s(item))))]})],2)}`
)
})
})
it
(
'
generate text with multiple statements
'
,
()
=>
{
it
(
'
generate text with multiple statements
'
,
()
=>
{
assertCodegen
(
assertCodegen
(
...
...
packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
浏览文件 @
b099924f
...
@@ -625,7 +625,7 @@ describe('codegen', () => {
...
@@ -625,7 +625,7 @@ describe('codegen', () => {
// normalize type: 2
// normalize type: 2
assertCodegen
(
assertCodegen
(
'
<div><child></child><template v-for="item in list">{{ item }}</template></div>
'
,
'
<div><child></child><template v-for="item in list">{{ item }}</template></div>
'
,
`with(this){return _c('div',[_c('child',{attrs:{"_i":1}}),_l((_$s(2,'f',{forItems:list})),function(item,$10,$20,$30){return [_v((_$s(("2-"+$30),'t0',_s(item))))]})],2)}`
`with(this){return _c('div',[_c('child',{attrs:{"_i":1}}),_l((_$s(2,'f',{forItems:list
,fill:true
})),function(item,$10,$20,$30){return [_v((_$s(("2-"+$30),'t0',_s(item))))]})],2)}`
)
)
})
})
...
...
packages/uni-template-compiler/__tests__/demo.js
浏览文件 @
b099924f
const
compiler
=
require
(
'
../lib
'
)
const
compiler
=
require
(
'
../lib
'
)
const
res
=
compiler
.
compile
(
const
res
=
compiler
.
compile
(
`
`
<
view><page-meta/><view><button></button></view></view
>
<
div><template v-for="item in items">text</template></div
>
`
,
{
`
,
{
miniprogram
:
true
,
miniprogram
:
true
,
resourcePath
:
'
/User/fxy/Documents/test.wxml
'
,
resourcePath
:
'
/User/fxy/Documents/test.wxml
'
,
...
@@ -14,9 +14,9 @@ const res = compiler.compile(
...
@@ -14,9 +14,9 @@ const res = compiler.compile(
mp
:
{
mp
:
{
platform
:
'
mp-weixin
'
platform
:
'
mp-weixin
'
},
},
filterModules
:
[
'
swipe
'
]
filterModules
:
[
'
swipe
'
]
,
//
service: true,
service
:
true
,
//
view: true
view
:
true
})
})
console
.
log
(
require
(
'
util
'
).
inspect
(
res
,
{
console
.
log
(
require
(
'
util
'
).
inspect
(
res
,
{
...
...
packages/uni-template-compiler/lib/app/parser/base-parser.js
浏览文件 @
b099924f
...
@@ -33,9 +33,14 @@ function parseIf (el, createGenVar, isScopedSlot) {
...
@@ -33,9 +33,14 @@ function parseIf (el, createGenVar, isScopedSlot) {
el
.
if
=
createGenVar
(
el
.
attrsMap
[
ID
],
isScopedSlot
)(
V_IF
,
el
.
if
)
el
.
if
=
createGenVar
(
el
.
attrsMap
[
ID
],
isScopedSlot
)(
V_IF
,
el
.
if
)
}
}
function
parseFor
(
el
,
createGenVar
,
isScopedSlot
)
{
function
parseFor
(
el
,
createGenVar
,
isScopedSlot
,
fill
=
false
)
{
if
(
el
.
for
&&
isVar
(
el
.
for
))
{
if
(
el
.
for
&&
isVar
(
el
.
for
))
{
el
.
for
=
createGenVar
(
el
.
forId
,
isScopedSlot
)(
V_FOR
,
`{forItems:
${
el
.
for
}
}`
)
el
.
for
=
createGenVar
(
el
.
forId
,
isScopedSlot
)(
V_FOR
,
fill
?
`{forItems:
${
el
.
for
}
,fill:true}`
:
`{forItems:
${
el
.
for
}
}`
)
return
true
return
true
}
}
}
}
...
...
packages/uni-template-compiler/lib/app/service.js
浏览文件 @
b099924f
...
@@ -85,6 +85,20 @@ function parseComponentAttrs (el, genVar) {
...
@@ -85,6 +85,20 @@ function parseComponentAttrs (el, genVar) {
})
})
}
}
function
checkAutoFill
(
el
)
{
if
(
el
.
for
&&
(
el
.
tag
===
'
template
'
||
el
.
tag
===
'
block
'
)
&&
!
el
.
children
.
find
(
child
=>
child
.
type
===
1
)
)
{
return
true
}
return
false
}
function
transformNode
(
el
,
parent
,
state
,
isScopedSlot
)
{
function
transformNode
(
el
,
parent
,
state
,
isScopedSlot
)
{
if
(
el
.
type
===
3
)
{
if
(
el
.
type
===
3
)
{
return
return
...
@@ -111,7 +125,7 @@ function transformNode (el, parent, state, isScopedSlot) {
...
@@ -111,7 +125,7 @@ function transformNode (el, parent, state, isScopedSlot) {
const
genVar
=
createGenVar
(
el
.
attrsMap
[
ID
],
isScopedSlot
)
const
genVar
=
createGenVar
(
el
.
attrsMap
[
ID
],
isScopedSlot
)
parseIs
(
el
,
genVar
)
parseIs
(
el
,
genVar
)
parseFor
(
el
,
createGenVar
,
isScopedSlot
)
parseFor
(
el
,
createGenVar
,
isScopedSlot
,
checkAutoFill
(
el
)
)
parseKey
(
el
,
isScopedSlot
)
parseKey
(
el
,
isScopedSlot
)
parseIf
(
el
,
createGenVar
,
isScopedSlot
)
parseIf
(
el
,
createGenVar
,
isScopedSlot
)
...
...
packages/uni-template-compiler/lib/app/util.js
浏览文件 @
b099924f
...
@@ -170,9 +170,15 @@ function processForKey (el) {
...
@@ -170,9 +170,15 @@ function processForKey (el) {
const
keyIndex
=
forEl
.
children
.
indexOf
(
el
)
const
keyIndex
=
forEl
.
children
.
indexOf
(
el
)
el
.
key
=
`
${
forEl
.
forId
}
+'-
${
keyIndex
}
'+
${
it
}
`
el
.
key
=
`
${
forEl
.
forId
}
+'-
${
keyIndex
}
'+
${
it
}
`
}
else
{
// 当 template 下只有文本节点
}
else
{
// 当 template 下只有文本节点
if
(
el
.
children
&&
el
.
children
.
length
&&
!
el
.
children
.
find
(
child
=>
child
.
key
))
{
if
(
el
.
children
&&
el
.
children
.
length
&&
!
el
.
children
.
find
(
child
=>
child
.
type
===
1
)
)
{
el
.
children
[
0
].
parent
=
el
el
.
children
[
0
].
parent
=
el
el
.
children
[
0
].
key
=
`
${
forEl
.
forId
}
+'-0'+
${
it
}
`
if
(
!
el
.
children
.
find
(
child
=>
child
.
key
))
{
el
.
children
[
0
].
key
=
`
${
forEl
.
forId
}
+'-0'+
${
it
}
`
}
return
true
return
true
}
}
}
}
...
@@ -219,8 +225,6 @@ function removeRawAttr (el, name) {
...
@@ -219,8 +225,6 @@ function removeRawAttr (el, name) {
function
removeRawBindingAttr
(
el
,
name
)
{
function
removeRawBindingAttr
(
el
,
name
)
{
removeRawAttr
(
el
,
'
:
'
+
name
)
removeRawAttr
(
el
,
'
:
'
+
name
)
removeRawAttr
(
el
,
'
v-bind:
'
+
name
)
removeRawAttr
(
el
,
'
v-bind:
'
+
name
)
console
.
log
(
el
)
throw
new
Error
(
'
123
'
)
}
}
function
addHandler
(
el
,
name
,
value
,
important
)
{
function
addHandler
(
el
,
name
,
value
,
important
)
{
...
...
src/platforms/app-plus/service/bridge.js
浏览文件 @
b099924f
...
@@ -71,7 +71,7 @@ export function isTabBarPage (path = '') {
...
@@ -71,7 +71,7 @@ export function isTabBarPage (path = '') {
}
}
return
page
.
$page
.
meta
.
isTabBar
return
page
.
$page
.
meta
.
isTabBar
}
}
const
route
=
__uniRoutes
.
find
(
route
=>
route
.
path
.
slice
(
1
)
===
path
)
const
route
=
__uniRoutes
.
find
(
route
=>
route
.
path
.
replace
(
/^
\/
/
,
''
)
===
path
.
replace
(
/^
\/
/
,
''
)
)
return
route
&&
route
.
meta
.
isTabBar
return
route
&&
route
.
meta
.
isTabBar
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
...
...
src/platforms/app-plus/service/framework/plugins/data.js
浏览文件 @
b099924f
import
{
import
{
guid
,
guid
,
hasOwn
,
hasOwn
,
isObject
,
camelize
camelize
}
from
'
uni-shared
'
}
from
'
uni-shared
'
...
@@ -164,11 +165,29 @@ function setData (id, name, value) {
...
@@ -164,11 +165,29 @@ function setData (id, name, value) {
return
((
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{}))[
name
]
=
value
)
return
((
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{}))[
name
]
=
value
)
}
}
function
fillVForData
(
forItems
,
vForData
)
{
let
i
,
l
if
(
Array
.
isArray
(
forItems
)
||
typeof
forItems
===
'
string
'
)
{
for
(
i
=
0
,
l
=
forItems
.
length
;
i
<
l
;
i
++
)
{
vForData
[
i
]
=
i
}
}
else
if
(
typeof
forItems
===
'
number
'
)
{
for
(
i
=
0
;
i
<
forItems
;
i
++
)
{
vForData
[
i
]
=
i
}
}
else
if
(
isObject
(
forItems
))
{
for
(
i
=
0
,
l
=
Object
.
keys
(
forItems
).
length
;
i
<
l
;
i
++
)
{
vForData
[
i
]
=
i
}
}
}
function
setForData
(
id
,
value
)
{
function
setForData
(
id
,
value
)
{
const
diffData
=
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{})
const
diffData
=
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{})
const
vForData
=
diffData
[
V_FOR
]
||
(
diffData
[
V_FOR
]
=
[])
const
vForData
=
diffData
[
V_FOR
]
||
(
diffData
[
V_FOR
]
=
[])
if
(
value
.
forItems
)
{
if
(
value
.
forItems
)
{
value
.
fill
&&
fillVForData
(
value
.
forItems
,
vForData
)
return
value
.
forItems
return
value
.
forItems
}
}
...
...
src/platforms/h5/components/system-routes/open-location/index.vue
浏览文件 @
b099924f
...
@@ -70,7 +70,7 @@ export default {
...
@@ -70,7 +70,7 @@ export default {
},
},
_nav
()
{
_nav
()
{
var
url
=
var
url
=
`https://apis.map.qq.com/uri/v1/routeplan?type=drive&to=
${
encodeURIComponent
(
this
.
name
)}
&tocoord=
${
this
.
latitude
}
,
${
this
.
longitude
}
&referer=
${
referer
}
`
`https://apis.map.qq.com/uri/v1/routeplan?type=drive&to=
${
encodeURIComponent
(
this
.
name
||
'
目的地
'
)}
&tocoord=
${
this
.
latitude
}
,
${
this
.
longitude
}
&referer=
${
referer
}
`
this
.
$refs
.
map
.
src
=
url
this
.
$refs
.
map
.
src
=
url
}
}
}
}
...
...
src/shared/util.js
浏览文件 @
b099924f
...
@@ -13,6 +13,10 @@ export function isStr (str) {
...
@@ -13,6 +13,10 @@ export function isStr (str) {
return
typeof
str
===
'
string
'
return
typeof
str
===
'
string
'
}
}
export
function
isObject
(
obj
)
{
return
obj
!==
null
&&
typeof
obj
===
'
object
'
}
export
function
isPlainObject
(
obj
)
{
export
function
isPlainObject
(
obj
)
{
return
_toString
.
call
(
obj
)
===
'
[object Object]
'
return
_toString
.
call
(
obj
)
===
'
[object Object]
'
}
}
...
@@ -21,7 +25,7 @@ export function hasOwn (obj, key) {
...
@@ -21,7 +25,7 @@ export function hasOwn (obj, key) {
return
hasOwnProperty
.
call
(
obj
,
key
)
return
hasOwnProperty
.
call
(
obj
,
key
)
}
}
export
function
noop
()
{
}
export
function
noop
()
{}
export
function
toRawType
(
val
)
{
export
function
toRawType
(
val
)
{
return
_toString
.
call
(
val
).
slice
(
8
,
-
1
)
return
_toString
.
call
(
val
).
slice
(
8
,
-
1
)
...
@@ -91,4 +95,4 @@ export function debounce (fn, delay) {
...
@@ -91,4 +95,4 @@ export function debounce (fn, delay) {
export
function
kebabCase
(
string
)
{
export
function
kebabCase
(
string
)
{
return
string
.
replace
(
/
[
A-Z
]
/g
,
str
=>
'
-
'
+
str
.
toLowerCase
())
return
string
.
replace
(
/
[
A-Z
]
/g
,
str
=>
'
-
'
+
str
.
toLowerCase
())
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录