|
| 1 | +<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
| 2 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 3 | +**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* |
| 4 | + |
| 5 | +- [Single Page Applications with Vue.js](#single-page-applications-with-vuejs) |
| 6 | + - [Environment Setup - Build Process](#environment-setup---build-process) |
| 7 | + - [Project Files](#project-files) |
| 8 | + - [Package Management](#package-management) |
| 9 | + - [Web Server](#web-server) |
| 10 | + - [Web Server - Index.html](#web-server---indexhtml) |
| 11 | + - [Webpack - Setup](#webpack---setup) |
| 12 | + - [Dev Middleware](#dev-middleware) |
| 13 | + - [Hot Reloading](#hot-reloading) |
| 14 | + - [Linting](#linting) |
| 15 | + - [Single File Components](#single-file-components) |
| 16 | + - [Vue Component](#vue-component) |
| 17 | + |
| 18 | +<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 19 | + |
1 | 20 | # Single Page Applications with Vue.js |
2 | 21 |
|
3 | 22 | > Notes from Pluralsight [course](https://app.pluralsight.com/library/courses/vue-js-single-page-applications/table-of-contents) |
|
126 | 145 | Modify [build/webpack.base.config.js](build/webpack.base.config.js) to hook up linting into build process. |
127 | 146 |
|
128 | 147 | Now when server is restarted, build will fail on lint errors. |
| 148 | + |
| 149 | +## Single File Components |
| 150 | + |
| 151 | +Vue uses single file components, each file contains a template for html, a script for js and style for css. |
| 152 | + |
| 153 | +### Vue Component |
| 154 | + |
| 155 | +One way to do things is to declare a component using `Vue.component` method. |
| 156 | + |
| 157 | +On first load, client entry will mount view instance to the div with id of `app` and create an `<app></app>` element. |
| 158 | +`<app></app>` element is configured in app.js with a template: |
| 159 | + |
| 160 | +```javascript |
| 161 | +Vue.component('app', { |
| 162 | + template: ` |
| 163 | + <div id="app"> |
| 164 | + ... |
| 165 | +
|
| 166 | +const app = new Vue({ |
| 167 | + render: h => h('app') |
| 168 | +}) |
| 169 | +``` |
| 170 | + |
| 171 | +Therefore `<app></app>` element will be replaced with app template configuration. |
0 commit comments