diff --git a/content/docs/en/getting-started/4-upgrade-guide.md b/content/docs/en/getting-started/4-upgrade-guide.md index 8eea84a7..b86cafd4 100644 --- a/content/docs/en/getting-started/4-upgrade-guide.md +++ b/content/docs/en/getting-started/4-upgrade-guide.md @@ -1,20 +1,30 @@ --- title: Upgrade Guide -contributors: [rigor789, jlooper] +contributors: [rigor789, jlooper, ikoevska] outdated: false --- > Estimated time for the upgrade: **10-20 minutes**. -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: +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. + +## Upgrade overivew + +The new template has a different folder structure: ![New folder structure](/screenshots/old-new-folder-structure.png) -**Step 1** +The simplified upgrade process involves: + +1. Creating a new project from the updated template. +1. Copying files from your old app into the new one. +1. Rearranging and adding some files. + +## Step 1: Create new app -Start by creating a new app using the Vue-CLI template. +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. -> **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. +Run the following command to create a new project from the Vue-CLI template. ```shell $ npm install -g @vue/cli @vue/cli-init @@ -26,38 +36,49 @@ $ # or $ tns run ios --bundle ``` -The upgrade process involves copying files from your old app into the new project and then rearranging and adding some files. +## Step 2: Replace `App_Resources` -**Step 2: Replace App Resources** +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. -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. +## Step 3: Merge the `src` and `app` folders -**Step 3: Merge `src` and `app` folders** +Copy all the folders in `src` from your old app and paste them into the `app` folder in the new app. -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. +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. -**Step 4: Edit `main.js`** +## Step 4: Edit `main.js` -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). +Edit `main.js`'s Vue initialization block to resemble: -Prior to 4.0 the root element was a Frame, which was implicitly created by NativeScript when our application started. +```js +new Vue({ + render: h => h('frame', [h(HelloWorld)]), +}).$start(); +``` -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. +NativeScript 4.0 brings two major improvements: -To keep the previous behavior of having a single root Frame, you can change your root Vue instance to have a `` and a `` element. +* a new `` element +* a new way to change the root element of your app that lets you share common view elements across pages (navigations). -**Example** +Before NativeScript 4.0, the root element was a `` element which was implicitly created by NativeScript when the application started. -```js -// in prior versions +With the latest changes, `` and `` elements are longer automatically created. So, in NativeScript-Vue 2.0.0, you need to explicitly add these elements to your template. + +To keep the previous behavior of having a single root ``, you can change your root Vue instance to have a `` and a `` element. + +**Example: Adding `` and `` to the template** + +```JavaScript +// in older versions // this automatically created a Page new Vue({ template: `