Book Image

Vue.js 2 Web Development Projects

By : CHAU GUILLAUME
Book Image

Vue.js 2 Web Development Projects

By: CHAU GUILLAUME

Overview of this book

Do you want to make your web application amazingly responsive? Are you unhappy with your app's performance and looking forward to trying out ways to make your app more powerful? Then Vue.js, a framework for building user interfaces, is a great choice, and this book is the ideal way to put it through its paces. This book's project-based approach will get you to build six stunning applications from scratch and gain valuable insights in Vue.js 2.5. You'll start by learning the basics of Vue.js and create your first web app using directives along with rich and attractive user experiences. You will learn about animations and interactivity by creating a browser-based game. Using the available tools and preprocessor, you will learn how to create multi-page apps with plugins. You will create highly efficient and performant functional components for your app. Next, you will create your own online store and optimize it. Finally, you will integrate Vue.js with the real-time Meteor library and create a dashboard showing real-time data. By the end of this book you will have enough skills and will have worked through enough examples of real Vue.js projects to create interactive professional web applications with Vue.js 2.5.
Table of Contents (15 chapters)

Blog posts and comments


In this last part, we are going to add the blog content to the app. Each blog post will have a position and an optional place ID from Google Maps (so the place can be described, for example, as "Restaurant A"). We will load the posts that fit in the visible bounds of the map and each one will appear as a marker with a custom icon. When clicking on a marker, the right side panel will display the post content and a list of comments. Clicking anywhere else on the map will create a draft post at this location in the Vuex store and display a form to write its content and save it in the right side panel.

Posts store module

Let's start by creating a new posts namespaced Vuex module to manage shared data related to the blog posts:

  1. Create a new store/posts.js file with those state properties:
      export default {
namespaced: true,

state () {
          return {
            // New post being created
draft: null,
            // Bounds of the last fetching
            // To prevent...