From c02594335a0f6f12a9bfcbc058fc01f0608c6578 Mon Sep 17 00:00:00 2001 From: Janos Hrubos <33330538+janoshrubos@users.noreply.github.com> Date: Tue, 31 Aug 2021 10:52:05 +0200 Subject: [PATCH] feat: tutorial wip --- .vitepress/config.js | 1 + tutorial.md | 481 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 482 insertions(+) create mode 100644 tutorial.md diff --git a/.vitepress/config.js b/.vitepress/config.js index 5202ea3a..9fc6c72e 100644 --- a/.vitepress/config.js +++ b/.vitepress/config.js @@ -129,6 +129,7 @@ function getSidebar() { text: 'Basics', children: [ { text: 'Introduction', link: '/introduction' }, + { text: 'Tutorial', link: '/tutorial' }, { text: 'Environment Setup', link: '/environment-setup', diff --git a/tutorial.md b/tutorial.md new file mode 100644 index 00000000..35ec18ce --- /dev/null +++ b/tutorial.md @@ -0,0 +1,481 @@ +--- +title: Tutorial +--- + +## Vue + +### Getting Started + +Are you ready to build your app with the tools you already know? + + + +```cli +npm i nativescript -g +ns create myCoolApp --vue +``` + + + +```cli +yarn global add nativescript +ns create myCoolApp --vue +``` + +### Hello World + +Let's see what the basic app has out of the box, and break down what's happening behind the scenes. + +```js +// app.js +import Vue from 'nativescript-vue' +import Home from './components/Home' + +new Vue({ + render: h => h('frame', [h(Home)]) +}).$start() +``` + +We are creating a new Vue application, and specifying a render function that will render our `Home.vue` in a frame (we will cover frames at a later point). Then we are calling `$start` without any arguments. + +On the web we would pass an element id to mount, but in NativeScript, there is no DOM that we are attaching to, so we simply don't need to pass in anything. The elements rendered by `Home.vue` will be created and automatically displayed when the application has been booted up. + +Let's explore what `Home.vue` does... + +```vue + + +``` + +Here we have a `` component that represents an application screen. We also have a`` and a `