Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
9be8526b
U
uni-app
项目概览
DCloud
/
uni-app
30 天 前同步成功
通知
702
Star
38704
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9be8526b
编写于
10月 31, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(v3): keep-alive
上级
75234f8f
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
5972 addition
and
3724 deletion
+5972
-3724
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+9
-9
packages/uni-app-plus/dist/service.runtime.esm.js
packages/uni-app-plus/dist/service.runtime.esm.js
+20
-11
packages/uni-app-plus/dist/view.css
packages/uni-app-plus/dist/view.css
+1393
-1
packages/uni-app-plus/dist/view.umd.js
packages/uni-app-plus/dist/view.umd.js
+4435
-3673
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
...ompiler/__tests__/compiler-app-plus-extra.service.spec.js
+11
-0
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
...e-compiler/__tests__/compiler-app-plus-extra.view.spec.js
+10
-0
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__/compiler-app-plus.view.spec.js
...emplate-compiler/__tests__/compiler-app-plus.view.spec.js
+1
-1
packages/uni-template-compiler/__tests__/demo.js
packages/uni-template-compiler/__tests__/demo.js
+1
-1
packages/uni-template-compiler/lib/app/optimizer.js
packages/uni-template-compiler/lib/app/optimizer.js
+7
-3
packages/uni-template-compiler/lib/app/parser/base-parser.js
packages/uni-template-compiler/lib/app/parser/base-parser.js
+11
-0
packages/uni-template-compiler/lib/app/parser/component-parser.js
.../uni-template-compiler/lib/app/parser/component-parser.js
+5
-4
packages/uni-template-compiler/lib/app/service.js
packages/uni-template-compiler/lib/app/service.js
+2
-0
packages/uni-template-compiler/lib/app/util.js
packages/uni-template-compiler/lib/app/util.js
+4
-1
packages/uni-template-compiler/lib/app/view.js
packages/uni-template-compiler/lib/app/view.js
+4
-1
packages/uni-template-compiler/lib/util.js
packages/uni-template-compiler/lib/util.js
+6
-2
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
...i-plugin-uni/packages/webpack-uni-app-loader/view/main.js
+4
-2
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/script.js
...plugin-uni/packages/webpack-uni-app-loader/view/script.js
+11
-3
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
...i-plugin-uni/packages/webpack-uni-app-loader/view/util.js
+11
-3
packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js
...pack-uni-mp-loader/lib/babel/scoped-component-traverse.js
+26
-8
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
9be8526b
...
...
@@ -3173,7 +3173,7 @@ var serviceContext = (function () {
return
invokeVmMethodWithoutArgs
(
ctx
,
'
pause
'
)
},
seek
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
seek
'
,
args
)
return
invokeVmMethod
(
ctx
,
'
seek
'
,
args
.
position
)
},
stop
(
ctx
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
stop
'
)
...
...
@@ -3182,7 +3182,7 @@ var serviceContext = (function () {
return
invokeVmMethod
(
ctx
,
'
sendDanmu
'
,
args
)
},
playbackRate
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
playbackRate
'
,
args
)
return
invokeVmMethod
(
ctx
,
'
playbackRate
'
,
args
.
rate
)
},
requestFullScreen
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
requestFullScreen
'
,
args
)
...
...
@@ -7999,7 +7999,7 @@ var serviceContext = (function () {
createMapContext
:
createMapContext$1
});
const
RATES
=
[
0.5
,
0.8
,
1.0
,
1.25
,
1.5
];
const
RATES
=
[
0.5
,
0.8
,
1.0
,
1.25
,
1.5
,
2.0
];
function
operateVideoPlayer$3
(
videoId
,
pageVm
,
type
,
data
)
{
invokeMethod
(
'
operateVideoPlayer
'
,
videoId
,
pageVm
,
type
,
data
);
...
...
@@ -8021,8 +8021,8 @@ var serviceContext = (function () {
operateVideoPlayer$3
(
this
.
id
,
this
.
pageVm
,
'
stop
'
);
}
seek
(
position
)
{
operateVideoPlayer$3
(
this
.
id
,
this
.
pageVm
,
'
seek
'
,
{
position
operateVideoPlayer$3
(
this
.
id
,
this
.
pageVm
,
'
seek
'
,
{
position
});
}
sendDanmu
(
args
)
{
...
...
@@ -8032,12 +8032,12 @@ var serviceContext = (function () {
if
(
!~
RATES
.
indexOf
(
rate
))
{
rate
=
1.0
;
}
operateVideoPlayer$3
(
this
.
id
,
this
.
pageVm
,
'
playbackRate
'
,
{
rate
operateVideoPlayer$3
(
this
.
id
,
this
.
pageVm
,
'
playbackRate
'
,
{
rate
});
}
requestFullScreen
()
{
operateVideoPlayer$3
(
this
.
id
,
this
.
pageVm
,
'
requestFullScreen
'
);
requestFullScreen
(
args
=
{}
)
{
operateVideoPlayer$3
(
this
.
id
,
this
.
pageVm
,
'
requestFullScreen
'
,
args
);
}
exitFullScreen
()
{
operateVideoPlayer$3
(
this
.
id
,
this
.
pageVm
,
'
exitFullScreen
'
);
...
...
packages/uni-app-plus/dist/service.runtime.esm.js
浏览文件 @
9be8526b
...
...
@@ -695,7 +695,13 @@ var uid = 0;
* directives subscribing to it.
*/
var
Dep
=
function
Dep
()
{
this
.
id
=
uid
++
;
// fixed by xxxxxx (nvue vuex)
/* eslint-disable no-undef */
if
(
typeof
SharedObject
!==
'
undefined
'
){
this
.
id
=
SharedObject
.
uid
++
;
}
else
{
this
.
id
=
uid
++
;
}
this
.
subs
=
[];
};
...
...
@@ -708,8 +714,8 @@ Dep.prototype.removeSub = function removeSub (sub) {
};
Dep
.
prototype
.
depend
=
function
depend
()
{
if
(
Dep
.
target
)
{
Dep
.
target
.
addDep
(
this
);
if
(
Dep
.
SharedObject
.
target
)
{
// fixed by xxxxxx
Dep
.
SharedObject
.
target
.
addDep
(
this
);
}
};
...
...
@@ -730,17 +736,20 @@ Dep.prototype.notify = function notify () {
// The current target watcher being evaluated.
// This is globally unique because only one watcher
// can be evaluated at a time.
Dep
.
target
=
null
;
var
targetStack
=
[];
// fixed by xxxxxx (nvue shared vuex)
/* eslint-disable no-undef */
Dep
.
SharedObject
=
typeof
SharedObject
!==
'
undefined
'
?
SharedObject
:
{};
Dep
.
SharedObject
.
target
=
null
;
Dep
.
SharedObject
.
targetStack
=
[];
function
pushTarget
(
target
)
{
targetStack
.
push
(
target
);
Dep
.
target
=
target
;
Dep
.
SharedObject
.
targetStack
.
push
(
target
);
Dep
.
SharedObject
.
target
=
target
;
}
function
popTarget
()
{
targetStack
.
pop
();
Dep
.
target
=
targetStack
[
targetStack
.
length
-
1
];
Dep
.
SharedObject
.
targetStack
.
pop
();
Dep
.
SharedObject
.
target
=
Dep
.
SharedObject
.
targetStack
[
Dep
.
SharedObject
.
targetStack
.
length
-
1
];
}
/* */
...
...
@@ -1019,7 +1028,7 @@ function defineReactive$$1 (
configurable
:
true
,
get
:
function
reactiveGetter
()
{
var
value
=
getter
?
getter
.
call
(
obj
)
:
val
;
if
(
Dep
.
target
)
{
if
(
Dep
.
SharedObject
.
target
)
{
// fixed by xxxxxx
dep
.
depend
();
if
(
childOb
)
{
childOb
.
dep
.
depend
();
...
...
@@ -4843,7 +4852,7 @@ function createComputedGetter (key) {
if
(
watcher
.
dirty
)
{
watcher
.
evaluate
();
}
if
(
Dep
.
target
)
{
if
(
Dep
.
SharedObject
.
target
)
{
// fixed by xxxxxx
watcher
.
depend
();
}
return
watcher
.
value
...
...
packages/uni-app-plus/dist/view.css
浏览文件 @
9be8526b
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/view.umd.js
浏览文件 @
9be8526b
此差异已折叠。
点击以展开。
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
浏览文件 @
9be8526b
...
...
@@ -70,6 +70,17 @@ describe('codegen', () => {
'
<current-user v-slot="{ user }">{{ user.firstName }}</current-user>
'
,
`with(this){return _c('current-user',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function({ user }){return [_v((_$s(0,'t0',_s(user.firstName))))]}}])})}`
)
})
it
(
'
generate keep-alive
'
,
()
=>
{
assertCodegen
(
`<keep-alive exclude="componentWithStatus1"><component is="componentWithStatus"/></keep-alive>`
,
`with(this){return _c('keep-alive',{attrs:{"exclude":"componentWithStatus1","_i":0}},[_c("componentWithStatus",{tag:"component",attrs:{"_i":1}})],1)}`
)
assertCodegen
(
`<keep-alive :exclude="componentWithStatus1"><component :is="'componentWithStatus'+index"/></keep-alive>`
,
`with(this){return _c('keep-alive',{attrs:{"exclude":_$s(0,'a-exclude',componentWithStatus1),"_i":0}},[_c(_$s(1,'is','componentWithStatus'+index),{tag:"component",attrs:{"_i":1}})],1)}`
)
})
})
/* eslint-enable quotes */
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
浏览文件 @
9be8526b
...
...
@@ -45,6 +45,16 @@ describe('codegen', () => {
'
<current-user v-slot="{ user }">{{ user.firstName }}</current-user>
'
,
`with(this){return _c('current-user',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function({ user }){return [_v((_$g(0,'t0')))]}}])})}`
)
})
it
(
'
generate keep-alive
'
,
()
=>
{
assertCodegen
(
`<keep-alive exclude="componentWithStatus1"><component is="componentWithStatus"/></keep-alive>`
,
`with(this){return _c('keep-alive',{attrs:{"exclude":"componentWithStatus1","_i":0}},[_c("componentWithStatus",{tag:"component",attrs:{"_i":1}})],1)}`
)
assertCodegen
(
`<keep-alive :exclude="componentWithStatus1"><component :is="'componentWithStatus'+index"/></keep-alive>`
,
`with(this){return _c('keep-alive',{attrs:{"exclude":_$g(0,'a-exclude'),"_i":0}},[_c(_$g(1,'is'),{tag:"component",attrs:{"_i":1}})],1)}`
)
})
})
/* eslint-enable quotes */
packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
浏览文件 @
9be8526b
...
...
@@ -576,7 +576,7 @@ describe('codegen', () => {
)
assertCodegen
(
'
<div :is="component1"></div>
'
,
`with(this){return _c(
component1
,{tag:"div"})}`
`with(this){return _c(
_$s(0,'is',component1)
,{tag:"div"})}`
)
// maybe a component and normalize type should be 1
assertCodegen
(
...
...
packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
浏览文件 @
9be8526b
...
...
@@ -576,7 +576,7 @@ describe('codegen', () => {
)
assertCodegen
(
'
<div :is="component1"></div>
'
,
`with(this){return _c(
component1
,{tag:"v-uni-view",attrs:{"_i":0}})}`
`with(this){return _c(
_$g(0,'is')
,{tag:"v-uni-view",attrs:{"_i":0}})}`
)
// maybe a component and normalize type should be 1
assertCodegen
(
...
...
packages/uni-template-compiler/__tests__/demo.js
浏览文件 @
9be8526b
const
compiler
=
require
(
'
../lib
'
)
const
res
=
compiler
.
compile
(
`
<
div :id="'a'+b">A{{ d | e | f }}B{{text}}C</div
>
<
keep-alive exclude="componentWithStatus1"><component is="componentWithStatus"/></keep-alive
>
`
,
{
resourcePath
:
'
/User/fxy/Documents/test.wxml
'
,
isReservedTag
:
function
(
tag
)
{
...
...
packages/uni-template-compiler/lib/app/optimizer.js
浏览文件 @
9be8526b
...
...
@@ -14,7 +14,11 @@ function no (a, b, c) {
}
function
isBuiltInTag
(
tag
)
{
if
(
tag
===
'
slot
'
||
tag
===
'
component
'
)
{
if
(
tag
===
'
slot
'
||
tag
===
'
component
'
||
tag
===
'
keep-alive
'
)
{
return
true
}
}
...
...
@@ -48,11 +52,11 @@ function markStatic (node) {
}
delete
node
.
attrs
}
if
(
node
.
type
===
1
)
{
if
(
node
.
type
===
1
)
{
delete
node
.
staticClass
delete
node
.
staticStyle
if
(
node
.
attrs
&&
!
isComponent
(
node
.
tag
))
{
// 移除静态属性
if
(
node
.
attrs
&&
!
isComponent
(
node
.
tag
)
&&
node
.
tag
!==
'
keep-alive
'
)
{
// 移除静态属性
node
.
attrs
=
node
.
attrs
.
filter
(
attr
=>
attr
.
name
===
ID
||
isVar
(
attr
.
value
))
}
...
...
packages/uni-template-compiler/lib/app/parser/base-parser.js
浏览文件 @
9be8526b
const
{
ID
,
C_IS
,
V_IF
,
V_FOR
,
V_ELSE_IF
,
...
...
@@ -8,6 +9,15 @@ const {
const
parseTextExpr
=
require
(
'
./text-parser
'
)
function
parseIs
(
el
,
genVar
)
{
if
(
!
el
.
component
)
{
return
}
if
(
isVar
(
el
.
component
))
{
el
.
component
=
genVar
(
C_IS
,
el
.
component
)
}
}
function
parseIf
(
el
,
createGenVar
)
{
if
(
!
el
.
if
)
{
return
...
...
@@ -60,6 +70,7 @@ function parseText (el, parent, state) {
}
module
.
exports
=
{
parseIs
,
parseIf
,
parseFor
,
parseText
,
...
...
packages/uni-template-compiler/lib/app/parser/component-parser.js
浏览文件 @
9be8526b
const
{
ID
,
hasOwn
ID
}
=
require
(
'
../util
'
)
const
tags
=
require
(
'
../../../../uni-cli-shared/lib/tags
'
)
const
{
isComponent
}
=
require
(
'
../../util
'
)
// 仅限 view 层
module
.
exports
=
function
parseComponent
(
el
)
{
// 需要把自定义组件的 attrs, props 全干掉
if
(
el
.
tag
&&
!
hasOwn
(
tags
,
el
.
tag
.
replace
(
'
v-uni-
'
,
''
)
))
{
if
(
el
.
tag
&&
isComponent
(
el
.
tag
))
{
// 仅保留 ID
el
.
attrs
&&
(
el
.
attrs
=
el
.
attrs
.
filter
(
attr
=>
attr
.
name
===
ID
))
}
...
...
packages/uni-template-compiler/lib/app/service.js
浏览文件 @
9be8526b
...
...
@@ -14,6 +14,7 @@ const {
}
=
require
(
'
../util
'
)
const
{
parseIs
,
parseIf
,
parseFor
,
parseText
,
...
...
@@ -82,6 +83,7 @@ function transformNode (el, parent, state) {
const
genVar
=
createGenVar
(
el
.
attrsMap
[
ID
])
parseIs
(
el
,
genVar
)
parseFor
(
el
,
createGenVar
)
parseKey
(
el
)
...
...
packages/uni-template-compiler/lib/app/util.js
浏览文件 @
9be8526b
...
...
@@ -9,6 +9,8 @@ const ITERATOR2 = '$2'
const
ITERATOR3
=
'
$3
'
const
SET_DATA
=
'
_$s
'
const
GET_DATA
=
'
_$g
'
const
C_IS
=
'
is
'
const
V_FOR
=
'
f
'
const
V_IF
=
'
i
'
...
...
@@ -190,7 +192,8 @@ function addHandler (el, name, value, important) {
el
.
plain
=
false
}
module
.
exports
=
{
module
.
exports
=
{
C_IS
,
V_FOR
,
V_IF
,
V_ELSE_IF
,
...
...
packages/uni-template-compiler/lib/app/view.js
浏览文件 @
9be8526b
...
...
@@ -8,7 +8,8 @@ const {
traverseNode
}
=
require
(
'
./util
'
)
const
{
const
{
parseIs
,
parseIf
,
parseFor
,
parseText
,
...
...
@@ -74,6 +75,8 @@ function transformNode (el, parent, state) {
const
genVar
=
createGenVar
(
el
.
attrsMap
[
ID
])
parseIs
(
el
,
genVar
)
if
(
parseFor
(
el
,
createGenVar
))
{
if
(
el
.
alias
[
0
]
===
'
{
'
)
{
// <div><li v-for=" { a, b } in items"></li></div>
el
.
alias
=
'
$item
'
...
...
packages/uni-template-compiler/lib/util.js
浏览文件 @
9be8526b
...
...
@@ -183,9 +183,13 @@ const {
}
=
require
(
'
./h5
'
)
function
isComponent
(
tagName
)
{
if
(
tagName
===
'
block
'
||
tagName
===
'
template
'
)
{
if
(
tagName
===
'
block
'
||
tagName
===
'
template
'
||
tagName
===
'
keep-alive
'
)
{
return
false
}
}
return
!
hasOwn
(
tags
,
getTagName
(
tagName
.
replace
(
'
v-uni-
'
,
''
)))
}
...
...
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
浏览文件 @
9be8526b
...
...
@@ -17,7 +17,9 @@ const {
parseComponents
}
=
require
(
'
./util
'
)
function
getDefineComponents
(
components
)
{
function
getDefineComponents
({
components
})
{
return
components
.
map
(({
name
,
source
...
...
@@ -93,7 +95,7 @@ module.exports = function(source, map) {
return
`
import 'uni-pages'
function initView(){
${
getStylesCode
(
this
)}
${
getStylesCode
(
this
)}
injectStyles()
${
getDefineComponents
(
parseComponents
(
source
,
traverse
)).
join
(
'
\n
'
)}
UniViewJSBridge.publishHandler('webviewReady')
...
...
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/script.js
浏览文件 @
9be8526b
...
...
@@ -10,7 +10,7 @@ const {
parseComponents
}
=
require
(
'
./util
'
)
function
genComponentCode
(
components
)
{
function
genComponentCode
(
components
)
{
const
importCode
=
[]
const
componentsCode
=
[]
components
.
forEach
(({
...
...
@@ -24,12 +24,20 @@ function genComponentCode (components) {
return
[
importCode
.
join
(
'
\n
'
),
componentsCode
.
join
(
'
,
\n
'
)]
}
function
genCode
(
components
,
css
=
[])
{
function
genCode
({
components
,
options
},
css
=
[])
{
const
optionsCode
=
[]
Object
.
keys
(
options
).
forEach
(
name
=>
{
options
[
name
]
!==
null
&&
optionsCode
.
push
(
`
${
name
}
:
${
options
[
name
]}
`
)
})
const
[
importComponentCode
,
componentsCode
]
=
genComponentCode
(
components
)
// TODO js 内引用 css
return
`
${
importComponentCode
}
export default {
${
optionsCode
.
length
?(
optionsCode
.
join
(
'
,
'
)
+
'
,
'
):
''
}
data(){
return {}
},
...
...
@@ -40,7 +48,7 @@ export default {
`
}
module
.
exports
=
function
(
content
,
map
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
content
=
preprocessor
.
preprocess
(
content
,
jsPreprocessOptions
.
context
,
{
...
...
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
浏览文件 @
9be8526b
const
parser
=
require
(
'
@babel/parser
'
)
function
parseComponents
(
content
,
traverse
)
{
function
parseComponents
(
content
,
traverse
)
{
const
{
state
:
{
options
,
components
}
}
=
traverse
(
parser
.
parse
(
content
,
{
...
...
@@ -15,9 +16,16 @@ function parseComponents (content, traverse) {
'
classProperties
'
]
}),
{
components
:
[]
components
:
[],
options
:
{
name
:
null
,
inheritAttrs
:
null
}
})
return
components
return
{
components
,
options
}
}
module
.
exports
=
{
...
...
packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js
浏览文件 @
9be8526b
...
...
@@ -6,10 +6,27 @@ const {
}
=
require
(
'
./util
'
)
function
handleObjectExpression
(
declaration
,
path
,
state
)
{
if
(
state
.
options
)
{
// name,inheritAttrs
Object
.
keys
(
state
.
options
).
forEach
(
name
=>
{
const
optionProperty
=
declaration
.
properties
.
filter
(
prop
=>
{
return
t
.
isObjectProperty
(
prop
)
&&
t
.
isIdentifier
(
prop
.
key
)
&&
prop
.
key
.
name
===
name
})[
0
]
if
(
optionProperty
)
{
if
(
t
.
isStringLiteral
(
optionProperty
.
value
))
{
state
.
options
[
name
]
=
JSON
.
stringify
(
optionProperty
.
value
.
value
)
}
else
{
state
.
options
[
name
]
=
optionProperty
.
value
.
value
}
}
})
}
const
componentsProperty
=
declaration
.
properties
.
filter
(
prop
=>
{
return
t
.
isObjectProperty
(
prop
)
&&
t
.
isIdentifier
(
prop
.
key
)
&&
prop
.
key
.
name
===
'
components
'
t
.
isIdentifier
(
prop
.
key
)
&&
prop
.
key
.
name
===
'
components
'
})[
0
]
if
(
componentsProperty
&&
t
.
isObjectExpression
(
componentsProperty
.
value
))
{
...
...
@@ -27,7 +44,8 @@ function handleObjectExpression (declaration, path, state) {
module
.
exports
=
function
(
ast
,
state
=
{
type
:
'
Component
'
,
components
:
[]
components
:
[],
options
:
{}
})
{
babelTraverse
(
ast
,
{
ExportDefaultDeclaration
(
path
)
{
...
...
@@ -35,15 +53,15 @@ module.exports = function (ast, state = {
if
(
t
.
isObjectExpression
(
declaration
))
{
// export default {components:{}}
handleObjectExpression
(
declaration
,
path
,
state
)
}
else
if
(
t
.
isCallExpression
(
declaration
)
&&
t
.
isMemberExpression
(
declaration
.
callee
)
&&
declaration
.
arguments
.
length
===
1
)
{
// export default Vue.extend({components:{}})
t
.
isMemberExpression
(
declaration
.
callee
)
&&
declaration
.
arguments
.
length
===
1
)
{
// export default Vue.extend({components:{}})
if
(
declaration
.
callee
.
object
.
name
===
'
Vue
'
&&
declaration
.
callee
.
property
.
name
===
'
extend
'
)
{
'
extend
'
)
{
handleObjectExpression
(
declaration
.
arguments
[
0
],
path
,
state
)
}
}
else
if
(
t
.
isClassDeclaration
(
declaration
)
&&
declaration
.
decorators
&&
declaration
.
decorators
.
length
)
{
// export default @Component({components:{}}) class MyComponent extend Vue
declaration
.
decorators
&&
declaration
.
decorators
.
length
)
{
// export default @Component({components:{}}) class MyComponent extend Vue
const
componentDecorator
=
declaration
.
decorators
[
0
]
if
(
t
.
isCallExpression
(
componentDecorator
.
expression
))
{
const
args
=
componentDecorator
.
expression
.
arguments
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录