You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/en/getting-started/4-upgrade-guide.md
+39-31Lines changed: 39 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,24 @@
1
1
---
2
2
title: Upgrade Guide
3
-
contributors: [rigor789, jlooper]
3
+
contributors: [rigor789, jlooper, ikoevska]
4
4
outdated: false
5
5
---
6
6
7
7
> Estimated time for the upgrade: **10-20 minutes**.
8
8
9
-
If you scaffolded a NativeScript-Vue app using the 1.3.1 version of the Vue-CLI template, it's time to upgrade to the newest version, 2.0, and this guide will help you do that. The new template has a different folder structure from the older one:
9
+
If you scaffolded a NativeScript-Vue app using the 1.3.1 version of the Vue-CLI template, it's time to upgrade to the newest 2.0 version. This guide will help you do that.
10
+
11
+
The new template has a different folder structure from the older one:
The upgrade process involves creating a new project from the updated template, copying files from your old app into the new one, and then rearranging and adding some files.
16
+
17
+
## Step 1: Create new app
14
18
15
19
Start by creating a new app using the Vue-CLI template.
16
20
17
-
> **TIP:**Make sure you use the same preinstallation commands in this new project that you used when creating the older version; for example, if you installed Vuex in the CLI the first time, do it again now.
21
+
> **TIP:**In your new project, use the same preinstallation commands that you used when creating the older version. For example, if you installed Vuex in the CLI the first time, do it again now.
18
22
19
23
```shell
20
24
$ npm install -g @vue/cli @vue/cli-init
@@ -26,38 +30,41 @@ $ # or
26
30
$ tns run ios --bundle
27
31
```
28
32
29
-
The upgrade process involves copying files from your old app into the new project and then rearranging and adding some files.
33
+
## Step 2: Replace the app resources
34
+
35
+
First, copy your old app's `App_Resources` folder from `./template/app/`. Next, paste it into the new app's `app` folder. Make sure that you're replacing the new `App_Resources` folder.
30
36
31
-
**Step 2: Replace App Resources**
37
+
## Step 3: Merge the `src` and `app` folders
32
38
33
-
Copy your old app's `App_Resources` folder from `./template/app/` and paste it into the new app's `app` folder, replacing its `App_Resources` folder.
39
+
Copy all the folders in `src`from your old app and paste them into the `app` folder in the new app.
34
40
35
-
**Step 3: Merge `src` and `app` folders**
41
+
If you have custom fonts, move the `src/assets/fonts` folder to `app/fonts` to let NativeScript load them automatically.
36
42
37
-
Copy all the folders in `src` from your old app and paste them into the `app` folder in the new app. If you have custom fonts, move the `src/assets/fonts` folder to `app/fonts` in order to let NativeScript to load them automatically.
43
+
## Step 4: Edit `main.js`
38
44
39
-
**Step 4: Edit `main.js`**
45
+
NativeScript 4.0 introduced two major improvements:
40
46
41
-
NativeScript 4.0 introduced a new Frame element, and introduced a way to change the root element of our applications, allowing for sharing common view elements across pages (navigations).
47
+
* a new `<Frame>` element
48
+
* a way to change the root element of our applications that lets you share common view elements across pages (navigations).
42
49
43
-
Prior to 4.0 the root element was a Frame, which was implicitly created by NativeScript when our application started.
50
+
Prior to NativeScript 4.0, the root element was a `<Frame>` which was implicitly created by NativeScript when the application started.
44
51
45
-
With these changes, we are no longer able to automatically create a Frame and Page elements, so in 2.0.0 you are required to explicitly add these elements to your template.
52
+
With the latest changes, `<Frame>` and `<Page>` elements are longer automatically created. So, in NativeScript-Vue 2.0.0, you need to explicitly add these elements to your template.
46
53
47
-
To keep the previous behavior of having a single root Frame, you can change your root Vue instance to have a `<Frame>` and a `<Page>` element.
54
+
To keep the previous behavior of having a single root `<Frame>`, you can change your root Vue instance to have a `<Frame>` and a `<Page>` element.
48
55
49
56
**Example**
50
57
51
-
```js
52
-
// in prior versions
58
+
```JavaScript
59
+
// in older versions
53
60
// this automatically created a Page
54
61
newVue({
55
62
template:`<Label text="Hello world"/>`
56
63
}).$start()
57
64
```
58
65
59
-
```js
60
-
// in 2.0.0
66
+
```JavaScript
67
+
// in NativeScript-Vue 2.0.0
61
68
// the <Frame> and <Page> must exist in your template
62
69
newVue({
63
70
template:`
@@ -70,7 +77,7 @@ new Vue({
70
77
}).$start()
71
78
```
72
79
73
-
This allows us to use a shared SideDrawer across different pages for example:
80
+
This lets you use a shared element across different pages. For example, a `<SideDrawer>`:
74
81
75
82
```js
76
83
newVue({
@@ -95,11 +102,13 @@ new Vue({
95
102
}).$start();
96
103
```
97
104
98
-
**Step 5: Edit paths**
105
+
## Step 5: Edit paths
99
106
100
-
Since the folder structure has changed, you need to edit the paths in your new app to point to your styles, fonts, and images.
107
+
Because the folder structure has changed, you need to edit the paths in your new app to point to your styles, fonts, and images.
101
108
102
-
In your components, if you have images from your old app referenced like this:
109
+
**Example**
110
+
111
+
If you have images from your old app referenced like this:
If your app uses manual routing, please note that the syntax for passing props has changed.
125
+
If your app uses manual routing, the syntax for passing props has changed.
117
126
118
127
Old syntax:
119
128
@@ -147,14 +156,13 @@ this.$navigateTo(NewPage, {
147
156
});
148
157
```
149
158
150
-
151
-
**Step 7: Align `package.json`**
159
+
## Step 7: Align `package.json`
152
160
153
161
Copy the relevant values from your old app's root `package.json` file into the new app's root `package.json` file. This will most likely entail copying the `Dependencies:` block, but you might also need to realign the new app's app version and description at the top of `package.json`.
154
162
155
-
**Step 8: Clean and run**
163
+
## Step 8: Clean and run
156
164
157
-
At this point, it's a good idea to clean the new app's folders (if you have run it prior) and reinstall any dependencies.
165
+
At this point, it's a good idea to clean the new app's folders and reinstall any dependencies.
158
166
159
167
```shell
160
168
$ cd<project-name>
@@ -165,9 +173,9 @@ $ # or
165
173
$ tns run ios --bundle
166
174
```
167
175
168
-
**Step 8 (Optional): Try HMR**
176
+
## (Optional) Step 8: Try HMR
169
177
170
-
Just recently nativescript received support for HMR (Hot Module Replacement). The latest version of NativeScript-Vue supports it out of thebox, however you will need to install the latest (and greatest) version of the NativeScript CLI.
178
+
Just recently NativeScript received support for HMR (Hot Module Replacement). The latest version of NativeScript-Vue supports it out-of-the-box but you will need to install the latest (and greatest) version of the NativeScript CLI.
0 commit comments