Skip to content

Commit a676ddd

Browse files
fix: router-view transform less space
1 parent a0b12e9 commit a676ddd

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<transition>
33
<keep-alive>
4-
<router-view class="class one"></router-view>
4+
<router-view :key="key" class="class one"></router-view>
55
</keep-alive>
66
</transition>
77

88
<transition>
9-
<router-view class="class two"></router-view>
9+
<router-view :key="key" class="class two"></router-view>
1010
</transition>
1111
</template>
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
2-
<router-view class="class one" v-slot="{ Component }"><transition>
2+
<router-view :key="key" class="class one" v-slot="{ Component }"><transition>
33
<keep-alive>
44
<component :is="Component" />
55
</keep-alive>
66
</transition></router-view>
77

8-
<router-view class="class two" v-slot="{ Component }"><transition>
8+
<router-view :key="key" class="class two" v-slot="{ Component }"><transition>
99
<component :is="Component" />
1010
</transition></router-view>
1111
</template>

vue-transformations/router-view-keep-alive-transition.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ function fix(node: Node, source: string): Operation[] {
7171
if (routerView) {
7272
routerView = <VElement>routerView
7373
// get attributes text
74-
let attributeText = ''
75-
routerView.startTag.attributes.forEach(
76-
node => (attributeText += OperationUtils.getText(node, source))
77-
)
74+
let attributeText = routerView.startTag.attributes
75+
.map(attr => OperationUtils.getText(attr, source))
76+
.join(' ')
7877
// replace with vue-router-next syntax
7978
fixOperations.push(
8079
OperationUtils.replaceText(routerView, '<component :is="Component" />')

0 commit comments

Comments
 (0)