Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optimize method to determine whether the two path are the same in ensureUrl methods #3477

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/index.html
Expand Up @@ -18,6 +18,8 @@ <h1>Vue Router Examples</h1>
<li><a href="route-props">Route Props</a></li>
<li><a href="route-alias">Route Alias</a></li>
<li><a href="route-params">Route Params</a></li>
<li><a href="route-query-hash">Route Query Hash</a></li>
<li><a href="route-query-history">Route Query History</a></li>
<li><a href="router-errors">Router errors</a></li>
<li><a href="transitions">Transitions</a></li>
<li><a href="data-fetching">Data Fetching</a></li>
Expand Down
47 changes: 47 additions & 0 deletions examples/route-query-hash/app.js
@@ -0,0 +1,47 @@
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
mode: 'hash',
base: __dirname
})

new Vue({
router,
data () {
return {
historyLength: 0
}
},
template: `
<div id="app">
<h1>Route Query Hash</h1>
<ul>
<li><a @click="gotoArray">route-query-hash?a=1&b=2&a=2</a></li>
<li><a @click="gotoOne">route-query-hash?a=1&b=2</a></li>
<li><a @click="gotoTwo">route-query-hash?b=2&a=1</a></li>
</ul>
<div>
historyLength:<span id="historyLength">{{historyLength}}</span>
</div>
</div>
`,
created () {
this.historyLength = window.history.length
},
methods: {
gotoArray () {
window.location.replace('/route-query-hash/#/?a=1&b=2&a=2')
},
gotoOne () {
this.$router.push({ path: '/?a=1&b=2' })
this.historyLength = window.history.length
},
gotoTwo () {
this.$router.push({ path: '/?b=2&a=1' })
this.historyLength = window.history.length
}
}
}).$mount('#app')
6 changes: 6 additions & 0 deletions examples/route-query-hash/index.html
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<link rel="stylesheet" href="/global.css">
<a href="/">&larr; Examples index</a>
<div id="app"></div>
<script src="/__build__/shared.chunk.js"></script>
<script src="/__build__/route-query-hash.js"></script>
47 changes: 47 additions & 0 deletions examples/route-query-history/app.js
@@ -0,0 +1,47 @@
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
mode: 'history',
base: __dirname
})

new Vue({
router,
data () {
return {
historyLength: 0
}
},
template: `
<div id="app">
<h1>Route Query History</h1>
<ul>
<li><a @click="gotoArray">route-query-history?a=1&b=2&a=2</a></li>
<li><a @click="gotoOne">route-query-history?a=1&b=2</a></li>
<li><a @click="gotoTwo">route-query-history?b=2&a=1</a></li>
</ul>
<div>
historyLength:<span id="historyLength">{{historyLength}}</span>
</div>
</div>
`,
created () {
this.historyLength = window.history.length
},
methods: {
gotoArray () {
window.location.replace('/route-query-history/?a=1&b=2&a=2')
},
gotoOne () {
this.$router.push({ path: '/?a=1&b=2' })
this.historyLength = window.history.length
},
gotoTwo () {
this.$router.push({ path: '/?b=2&a=1' })
this.historyLength = window.history.length
}
}
}).$mount('#app')
6 changes: 6 additions & 0 deletions examples/route-query-history/index.html
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<link rel="stylesheet" href="/global.css">
<a href="/">&larr; Examples index</a>
<div id="app"></div>
<script src="/__build__/shared.chunk.js"></script>
<script src="/__build__/route-query-history.js"></script>