Vue.js Notebook
Nov-2020
Start
- Download node and install;
- Download vue;
~> npm install -g @vue/cli
Create Vue Project
~> vue create testPrj
Start Web Server, Run the App
~> cd testPrj testProj~> npm run serve
starts web server and your app at localhost:8080
Stop server and run GUI version of the Vue App Server
~> vue ui
starts dashboard at localhost:8000
Architecture
- Renderer is
<div id="app" />inpublic/index.html - Main engine is the
src/main.jsfile, imports vue and App object App.vuefile as an example:
<template>
<div id="app">
All view here.
<Header /> <!-- Component; Navigation etc. -->
</div>
<template>
<script>
// Header.js in that folder holds the similar architechture.
import Header from './componentes/layout/Header'
// sending up to the view
export default {
name: "app",
components: {
Header
}
}
</script>
<!-- scoped parameter (optional) means those
style are scoped only by this page. -->
<style scoped>
/* Standard CSS */
</style>
Header.vueobject imported byApp.vue
<template>
<header class="header">
<h1>TodoList</h1>
<div id="nav">
<!-- Routers gets installed as plugins
by Vue App Server Dashboard -->
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
</header>
</template>
<script>
export default {
name: "Header"
}
</script>
<!-- scoped parameter (optional) means
those style are scoped only by this page. -->
<style scoped>
header {
background-color: teal;
}
/* ... */
</style>
Routing
to be continued…
Cheat Sheet:
- https://appletree.or.kr/quick_reference_cards/JavaScript/Vue.js%20Cheat%20Sheet.pdf
- https://shortcode.dev/vue-cheatsheet