-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(router-view): add condition to see whether the tree is inactive (fix
#2552) (#2592) Fix #2552 <!-- Please make sure to read the Pull Request Guidelines: https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#pull-request-guidelines -->
- Loading branch information
Showing
5 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Vue from 'vue' | ||
import VueRouter from 'vue-router' | ||
|
||
Vue.use(VueRouter) | ||
|
||
const Wrap = { template: '<div>child: <router-view></router-view></div>' } | ||
|
||
const Index = { | ||
template: '<wrap />', | ||
components: { | ||
Wrap | ||
} | ||
} | ||
|
||
const IndexChild1 = { template: '<div class="current">index child1</div>' } | ||
const IndexChild2 = { template: '<div class="current">index child2</div>' } | ||
|
||
const Home = { template: '<div class="current">home</div>' } | ||
|
||
const router = new VueRouter({ | ||
mode: 'history', | ||
base: __dirname, | ||
routes: [ | ||
{ | ||
path: '/index', | ||
component: Index, | ||
children: [ | ||
{ | ||
path: 'child1', | ||
component: IndexChild1 | ||
}, | ||
{ | ||
path: 'child2', | ||
component: IndexChild2 | ||
} | ||
] | ||
}, | ||
{ | ||
path: '/home', | ||
component: Home | ||
} | ||
] | ||
}) | ||
|
||
new Vue({ | ||
router, | ||
template: ` | ||
<div id="app"> | ||
<ul> | ||
<li><router-link tag="a" to="/index/child1">index child 1</router-link></li> | ||
<li><router-link tag="a" to="/index/child2">index child 2</router-link></li> | ||
<li><router-link tag="a" to="/home">home</router-link></li> | ||
</ul> | ||
<keep-alive> | ||
<router-view></router-view> | ||
</keep-alive> | ||
</div> | ||
` | ||
}).$mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<link rel="stylesheet" href="/global.css"> | ||
<style> | ||
a.router-link-active, li.router-link-active a { | ||
color: #f66; | ||
} | ||
a.router-link-exact-active, li.router-link-exact-active a { | ||
border-bottom: 1px solid #f66; | ||
} | ||
</style> | ||
<a href="/">← Examples index</a> | ||
<div id="app"></div> | ||
<script src="/__build__/shared.chunk.js"></script> | ||
<script src="/__build__/keepalive-view.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
'keepalive view': function (browser) { | ||
browser | ||
.url('http://localhost:8080/keepalive-view/') | ||
.waitForElementVisible('#app', 1000) | ||
.assert.count('li a', 3) | ||
|
||
.click('li:nth-child(1) a') | ||
.assert.containsText('.current', 'index child1') | ||
|
||
.click('li:nth-child(2) a') | ||
.assert.containsText('.current', 'index child2') | ||
|
||
.click('li:nth-child(3) a') | ||
.assert.containsText('.current', 'home') | ||
|
||
// back to index child1 and check it | ||
.click('li:nth-child(1) a') | ||
.assert.containsText('.current', 'index child1') | ||
.end() | ||
} | ||
} |