Skip to content

Commit d840d3c

Browse files
committed
feat: use the new run method instead of the old start method
BREAKING CHANGE: nativescript 3.x will no longer work with this change because application.run has been added in 4.0
1 parent 7a3fe40 commit d840d3c

File tree

4 files changed

+91
-6
lines changed

4 files changed

+91
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"rollup-watch": "^4.3.1",
7575
"semver": "^5.5.0",
7676
"set-value": "^2.0.0",
77-
"tns-core-modules": "^3.4.0",
77+
"tns-core-modules": "4.0.0",
7878
"util-inspect": "^0.1.8",
7979
"vue": "^2.5.16"
8080
},

platform/nativescript/runtime/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { start, on, launchEvent } from 'tns-core-modules/application'
1+
import { run, on, launchEvent } from 'tns-core-modules/application'
22
import { warn } from 'core/util/index'
33
import { patch } from './patch'
44
import { mountComponent } from 'core/instance/lifecycle'
@@ -73,7 +73,7 @@ Vue.prototype.$start = function({ getRootView }) {
7373
: ensurePage(self.$el, self)
7474
})
7575

76-
start()
76+
run()
7777
}
7878

7979
export default Vue

samples/app/app-with-router-v2.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
const Vue = require('./nativescript-vue')
2+
const VueRouter = require('vue-router')
3+
const application = require('tns-core-modules/application')
4+
5+
Vue.config.silent = false
6+
Vue.config.debug = true
7+
Vue.use(VueRouter)
8+
9+
const Home = {
10+
template: `
11+
<Page>
12+
<StackLayout>
13+
<Button text="Go to details page..." @tap="$router.push('/detail/1')"/>
14+
</StackLayout>
15+
</Page>
16+
`
17+
}
18+
19+
const Detail = {
20+
template: `
21+
<Page>
22+
<GridLayout rows="*, *, *">
23+
<Label :text="'Detail for ' + $route.params.id" row="0"/>
24+
<Button text="Tab 2" @tap="$router.replace($route.path + '/tab2')"/>
25+
26+
<router-view row="1" />
27+
</GridLayout>
28+
</Page>
29+
`
30+
}
31+
32+
const DetailTab1 = {
33+
template: `
34+
<Label text="detail tab 1" />
35+
`
36+
}
37+
38+
const DetailTab2 = {
39+
template: `
40+
<Label text="detail tab 2" />
41+
`
42+
}
43+
44+
const router = new VueRouter({
45+
routes: [
46+
{ path: '/', component: Home },
47+
{
48+
path: '/detail/:id',
49+
component: Detail,
50+
children: [
51+
{ path: '/', component: DetailTab1 },
52+
{ path: 'tab2', component: DetailTab2 }
53+
]
54+
},
55+
{ path: '*', redirect: '/' }
56+
]
57+
})
58+
59+
router.push('/')
60+
61+
application.android.on('activityBackPressed', args => {
62+
if (router.history.stack.length > 1) {
63+
router.back()
64+
args.cancel = true
65+
}
66+
})
67+
68+
new Vue({
69+
router,
70+
template: `
71+
<GridLayout rows="*, 80">
72+
<Frame row="0">
73+
<router-view :key="$route.path" />
74+
</Frame>
75+
76+
<Label :text="$route.path"
77+
backgroundColor="#333" color="#eee"
78+
row="1" />
79+
</GridLayout>
80+
`
81+
}).$start({
82+
getRootView(vm) {
83+
return vm.$el.nativeView
84+
}
85+
})

samples/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
"nativescript": {
77
"id": "org.nativescript.vuesample",
88
"tns-ios": {
9-
"version": "3.4.0"
9+
"version": "4.0.1"
1010
},
1111
"tns-android": {
12-
"version": "3.4.0"
12+
"version": "4.0.1"
1313
}
1414
},
1515
"dependencies": {
1616
"nativescript-gradient": "^2.0.1",
1717
"nativescript-pager": "^7.1.3",
1818
"nativescript-pro-ui": "^3.3.0",
1919
"nativescript-theme-core": "^1.0.4",
20-
"tns-core-modules": "^3.4.0",
20+
"tns-core-modules": "4.0.0",
2121
"vue-router": "^3.0.1",
2222
"vuex": "^3.0.1"
2323
},

0 commit comments

Comments
 (0)