Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb58b36b

Browse files
committed
fix: defaultPath per navigator instance
1 parent99f9e36 commitb58b36b

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

‎components/Navigator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export default {
2929
},
3030
created(){
3131
this.defaultRouteComponent=this.$navigator._resolveComponent(
32-
this.$props.defaultRoute
32+
this.$props.defaultRoute,
33+
this.$props.id
3334
)
3435
},
3536
methods:{

‎index.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
importNavigatorfrom'./components/Navigator'
22

33
exportdefaultfunctioninstall(Vue,{routes}){
4+
letappRoot;
5+
conststart=Vue.prototype.$start
6+
Vue.prototype.$start=function(){
7+
appRoot=this
8+
start.call(this)
9+
}
410
Vue.component('Navigator',Navigator)
511

612
Object.keys(routes).map(path=>{
@@ -20,24 +26,29 @@ export default function install(Vue, {routes}) {
2026
data:{
2127
path:false,
2228
paths:{},
23-
defaultPath:'/'
29+
defaultPaths:{},
2430
},
2531
computed:{
2632
route(){
27-
returnroutes[this.path||this.defaultPath]
33+
returnthis.routes('navigator')
34+
},
35+
routes(){
36+
returnid=>routes[this.paths[id]||this.defaultPaths[id]]
2837
},
2938
},
3039
methods:{
31-
_resolveComponent(defaultPath){
32-
if(defaultPath)this.defaultPath=defaultPath
40+
_resolveComponent(defaultPath,id){
41+
if(defaultPath){
42+
this.$set(this.defaultPaths,id,defaultPath)
43+
}
3344

34-
if(this.route){
35-
returnthis.route.component
45+
if(this.routes(id)){
46+
returnthis.routes(id).component
3647
}
3748
returnfalse
3849
},
3950
_updatePath(path,id='navigator'){
40-
if(id==='navigator'){
51+
if(id==='navigator'){
4152
this.path=path
4253
}
4354
this.$set(this.paths,id,path)
@@ -48,17 +59,18 @@ export default function install(Vue, {routes}) {
4859

4960
if(!matchedRoute){
5061
if(TNS_ENV==='development'){
51-
thrownewError(`Navigating to a route that does not exist:${to}`)
62+
thrownewError(`[Navigator]Navigating to a route that does not exist:${to}`)
5263
}
5364
returnfalse
5465
}
5566

56-
options=Object.assign({frame:'navigator'},options)
67+
options=Object.assign({frame:'navigator'},options)
5768

5869
returnthis.$navigateTo(matchedRoute.component,options)
70+
.catch(err=>console.log(`[Navigator] Failed to navigate:${err}`))
5971
},
6072
back(options, ...args){
61-
options=Object.assign({frame:'navigator'},options)
73+
options=Object.assign({frame:'navigator'},options)
6274
returnthis.$navigateBack.call(this,options, ...args)
6375
}
6476
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp