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

Commita101fac

Browse files
committed
feat: add support for <router-view> in Frame
and fix wrong parent frame search function
1 parenta7cc25b commita101fac

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

‎platform/nativescript/runtime/components/frame.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
11
import{setFrame,deleteFrame}from'../../util/frame'
2+
import{PAGE_REF}from'./page'
23

34
exportdefault{
4-
name:'frame',
55
props:{
66
id:{
77
default:'default'
8+
},
9+
// injected by the template compiler
10+
hasRouterView:{
11+
default:false
12+
}
13+
},
14+
data(){
15+
return{
16+
pageRoutes:[]
817
}
918
},
1019
created(){
1120
setFrame(this.$props.id,this)
12-
this.cache={}
1321
},
1422
destroyed(){
1523
deleteFrame(this.$props.id)
1624
},
1725
render(h){
26+
letvnode=this.$slots.default
27+
if(this.hasRouterView&&this.isBackNavigation){
28+
this.isBackNavigation=false
29+
vnode=this.$el.nativeView.currentPage[PAGE_REF]||vnode
30+
}
31+
1832
returnh(
1933
'NativeFrame',
2034
{
2135
attrs:Object.assign({},this.$attrs,this.$props),
2236
on:this.$listeners
2337
},
24-
this.$slots.default
38+
vnode
2539
)
2640
},
2741
methods:{
@@ -38,6 +52,10 @@ export default {
3852
},
3953

4054
navigate(entry,back=false){
55+
if(this.isBackNavigation){
56+
console.log('skipping navigate()')
57+
return
58+
}
4159
constframe=this._getFrame()
4260

4361
if(back){
@@ -58,6 +76,18 @@ export default {
5876
if(isBackNavigation){
5977
page.off('navigatedFrom')
6078
this.$emit('back',entry)
79+
80+
if(!this.hasRouterView)return
81+
this.isBackNavigation=true
82+
83+
// since this was a page navigation
84+
// we need to find the previous page's path
85+
// and navigate back to it
86+
constlastPageRoute=this.pageRoutes.pop()
87+
while(this.$router.currentRoute.fullPath!==lastPageRoute){
88+
this.$router.go(-1)
89+
}
90+
this.$router.go(-1)
6191
}
6292
})
6393
entry.create=()=>page

‎platform/nativescript/runtime/components/page.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
exportconstPAGE_REF='__vuePageRef__'
2+
13
exportdefault{
2-
name:'page',
34
render(h){
45
returnh(
56
'NativePage',
@@ -11,9 +12,12 @@ export default {
1112
)
1213
},
1314
mounted(){
15+
this.$el.nativeView[PAGE_REF]=this
16+
1417
constframe=this._findParentFrame()
1518
if(frame){
1619
frame.notifyPageMounted(this)
20+
frame.pageRoutes.push(this.$route.fullPath)
1721
}
1822

1923
this.$nextTick(()=>{
@@ -29,7 +33,7 @@ export default {
2933
methods:{
3034
_findParentFrame(){
3135
letparentFrame=this.$parent
32-
while(parentFrame&&parentFrame.$options.name!=='frame'){
36+
while(parentFrame&&parentFrame.$options.name!=='Frame'){
3337
parentFrame=parentFrame.$parent
3438
}
3539

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp