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
+42-30Lines changed: 42 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -8,17 +8,23 @@ outdated: false
8
8
9
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
10
11
-
The new template has a different folder structure from the older one:
11
+
## Upgrade overivew
12
+
13
+
The new template has a different folder structure:
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.
17
+
The simplified upgrade process involves:
18
+
19
+
1. Creating a new project from the updated template.
20
+
1. Copying files from your old app into the new one.
21
+
1. Rearranging and adding some files.
16
22
17
23
## Step 1: Create new app
18
24
19
-
Start by creating a new app using the Vue-CLI template.
25
+
Use the Vue-CLI template to create a new app. Make sure to run the same preinstallation commands that you used for the old version. For example, if you installed Vuex in the CLI the first time, do it again now.
20
26
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.
27
+
Run the following command to create a new project from the Vue-CLI template.
22
28
23
29
```shell
24
30
$ npm install -g @vue/cli @vue/cli-init
@@ -30,30 +36,38 @@ $ # or
30
36
$ tns run ios --bundle
31
37
```
32
38
33
-
## Step 2: Replace the app resources
39
+
## Step 2: Replace `App_Resources`
34
40
35
41
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.
36
42
37
43
## Step 3: Merge the `src` and `app` folders
38
44
39
45
Copy all the folders in `src` from your old app and paste them into the `app` folder in the new app.
40
46
41
-
If you have custom fonts, move the `src/assets/fonts` folder to `app/fonts` to let NativeScript load them automatically.
47
+
If you have custom fonts, move the contents of the `src/assets/fonts` folder to `app/fonts`. This ensures that NativeScript will load your custom fonts automatically.
42
48
43
49
## Step 4: Edit `main.js`
44
50
45
-
NativeScript 4.0 introduced two major improvements:
51
+
Edit `main.js`'s Vue initialization block to resemble:
52
+
53
+
```js
54
+
newVue({
55
+
render:h=>h('frame', [h(HelloWorld)]),
56
+
}).$start();
57
+
```
58
+
59
+
NativeScript 4.0 brings two major improvements:
46
60
47
61
* 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).
62
+
* a new way to change the root element of your app that lets you share common view elements across pages (navigations).
49
63
50
-
Prior to NativeScript 4.0, the root element was a `<Frame>` which was implicitly created by NativeScript when the application started.
64
+
Before NativeScript 4.0, the root element was a `<Frame>` element which was implicitly created by NativeScript when the application started.
51
65
52
66
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.
53
67
54
68
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.
55
69
56
-
**Example**
70
+
**Example: Adding `<Frame>` and `<Page>` to the template**
57
71
58
72
```JavaScript
59
73
// in older versions
@@ -77,7 +91,9 @@ new Vue({
77
91
}).$start()
78
92
```
79
93
80
-
This lets you use a shared element across different pages. For example, a `<SideDrawer>`:
94
+
This lets you use a shared element across different pages.
95
+
96
+
**Example: Using a shared `<SideDrawer>` element**
81
97
82
98
```js
83
99
newVue({
@@ -94,39 +110,31 @@ new Vue({
94
110
}).$start()
95
111
```
96
112
97
-
In its simplest form, however, edit `main.js`'s Vue initialization block to resemble:
98
-
99
-
```js
100
-
newVue({
101
-
render:h=>h('frame', [h(HelloWorld)]),
102
-
}).$start();
103
-
```
104
-
105
113
## Step 5: Edit paths
106
114
107
115
Because the folder structure has changed, you need to edit the paths in your new app to point to your styles, fonts, and images.
108
116
109
-
**Example**
117
+
**Example: Changing image references**
110
118
111
-
If you have images from your old app referenced like this:
119
+
In your old app, you are likely to have referenced images like this.
If your app uses manual routing, the syntax for passing props has changed.
133
+
If your app uses manual routing, the syntax for passing props has changed. Note that this change might not be required in all projects.
126
134
127
-
Old syntax:
135
+
Your old syntax is likely to look like this.
128
136
129
-
```js
137
+
```JavaScript
130
138
this.$navigateTo(NewPage, {
131
139
transition: {},
132
140
transitionIOS: {},
@@ -141,9 +149,9 @@ this.$navigateTo(NewPage, {
141
149
});
142
150
```
143
151
144
-
New syntax:
152
+
To preserve the manual routing behavior in your new app, change your syntax to the following:
145
153
146
-
```js
154
+
```JavaScript
147
155
this.$navigateTo(NewPage, {
148
156
transition: {},
149
157
transitionIOS: {},
@@ -158,11 +166,13 @@ this.$navigateTo(NewPage, {
158
166
159
167
## Step 7: Align `package.json`
160
168
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`.
169
+
Copy the relevant values from your old app's root `package.json` file into the new app's root `package.json` file.
170
+
171
+
You will likely need to copy the `Dependencies:` block and, in some cases, realign the new app's app version and description at the top of `package.json`.
162
172
163
173
## Step 8: Clean and run
164
174
165
-
At this point, it's a good idea to clean the new app's folders and reinstall any dependencies.
175
+
Run the following command to clean the new app's folders and reinstall any dependencies.
166
176
167
177
```shell
168
178
$ cd<project-name>
@@ -175,7 +185,9 @@ $ tns run ios --bundle
175
185
176
186
## (Optional) Step 8: Try HMR
177
187
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.
188
+
NativeScript now provides support for HMR (Hot Module Replacement). The latest version of NativeScript-Vue provides out-of-the-box HMR support as well but requires the NativeScript CLI.
189
+
190
+
Run the following command to get HMR support by installing the latest and greatest version of the NativeScript CLI.
0 commit comments