Giter Club home page Giter Club logo

learning-vuejs-2's Introduction

Learning Vue.js 2

This is the code repository for Learning Vue.js 2, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

About the Book

Vue.js is one of the latest new frameworks to have piqued the interest of web developers due to its reactivity, reusable components, and ease of use. This book shows developers how to leverage its features to build high-performing, reactive web interfaces with Vue.js. From the initial structuring to full deployment, this book provides step-by-step guidance to developing an interactive web interface from scratch with Vue.js.

You will start by building a simple application in Vue.js which will let you observe its features

Instructions and Navigations

All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02.

The code will look like the following:

export default {
  components: {
    ShoppingListComponent,
    ShoppingListTitleComponent
  },
  computed: mapGetters({
  shoppinglists: 'getLists'
  })
}

The requirements for this book are the following:

  • Computer with an Internet connection
  • Text editor/IDE
  • Node.js

Related Products

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781786469946

learning-vuejs-2's People

Contributors

packt-itservice avatar packtutkarshr avatar praju89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learning-vuejs-2's Issues

Inconsistency in code sample for Chapter5/Pomodoro

Just a note to anyone following the book, Chapter 5.

According to this file :

Learning-Vuejs-2/chapter5/pomodoro/package.json

This sample is using Vue JS v1, and already has the components and vuex stuff (I assume specific for that version). There are also some differences in how the getters are defined for CountdownComponent.vue based in the book.

Code sample

  import { getMinutes, getSeconds } from '../vuex/getters'

  export default {
    vuex: {
      getters: {
        min: getMinutes,
        sec: getSeconds
      }
    }
  }

Book

import { mapGetters } from 'vuex'

export default {
  computed: mapGetters({
    min: 'getMinutes',
    sec: 'getSeconds'
  })
}

As a result, students cannot follow through (from scratch) with the chapter's exercise if taking the source code from Learning-Vuejs-2/chapter5/pomodoro.

Chapter 4, title changing in shopping-list2

In the text, the steps say to do the following:

  1. Bind the model title using the v-model directive to change-title-component in the template of the ShoppingListComponent.
  2. Export value in the props attribute of the ChangeTitleComponent.
  3. Create an onInput method inside the ChangeTitleComponent that will emit
    the native input method with the value of the event target.
  4. Bind value to input inside the ChangeTitleComponent component's template
    and the v-on directive with the onInput modifier.

In step 4, the functionality works fine without binding the value to input and declaring any props:

<...>
<input @input = "onInput"/>
<...>

So why do we need to bind value to input inside the ChangeTitleComponent component's template and declare props if we are not receiving and value props inside the component in ShoppingListComponent?
// ShoppingListComponent
<

// ChangeTitleComponent
<input :value = "value" @input ="onInput"/>

Chapter 6 - Pomodoro starting point

Just to highlight that the chapter6/pomodoro had jade templates and is using VueJS v1, not really a good starting point for plugin development.

Can you kindly help us out and let us have a good starting point to continue the chapter please thank you.

not working chapter 3 / shopping list component

alternative source code: https://flems.io/#0=N4Igxg9gdgzhA2BTEAucD4EMAONEBMQAaEGMAJw1QG0AGI2gXRIDMBLJGG0KTAW2RoAdAAsALn3jF0UMYlmoQAHgCEAWjUACJfjYA3TW3wBeADogc2c5rBYYMMzLGY2UROXMA+U1E3aRAEyewMCaYmxiSJoAvtFKAP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+mdJ8EIa0jQ6oxtsU48gjpiiYGGBWo11baqeh0vWmsLJ3QAigoIqAjpzhuAwhOVEhQRDtuxFADkYl60ngKJcYYjcUyOigGDWdPgF3qh7VYvgGbXBqCQCwMQjoACsead1QCEPnSY9b-iyDUDANgAAvcBxahD9wWGmzQR6BUnsJNgRNtA9AztQU6rurrFDupQLQMezAQBjoGH3A+IBeCBrQKGEclxyA4CEPKu9YAQ0kGkVINA4gxDrKwUe54YB8B3tw2IfDOBGMkZBsFYcrH1I4HiJ6oQgmABsAL7Dcbw3xmixHg0L1ktJRQq6kDQZdcOt1l6UDuvdWPCemGp4r2IfPaQFHFDUdowCpj88XRONyPgFgWBrQkL4Ng2emBnjHXRDAeIehVbxAAIxCFoEIAI7rvOGbkymRTFA2DYDEEhkgWHp4HGEoeQop7xJNzHkAA

Missing Unit Tests

The unit tests for createShoppingList & deleteShoppingList from actions.js in chapter 7 are missing from this repository. It's not exactly clear how to test these methods. Please add the tests or explain how to go about testing them here. As well, please go into further detail about the syntax in the method.

createShoppingList: (store, shoppinglist) => {
  return api.addNewShoppingList(shoppinglist).then(() => {
    store.dispatch('populateShoppingLists')
  }, () => {
    store.commit(types.ADD_SHOPPING_LIST, shoppinglist)
  })
}

I don't understand why are there two objects and one being call like () => {...}

Chapter 6 - Windows - Problem starting the json-server

In the book, there is a part where we should add a script entry to the package.json file so that we can easily start our server.

What worked for me was

"scripts": {
  "dev": "node build/dev-server.js",
  "server": "json-server --watch server/db.json",
  <...>
}

Windows machines don't have cURL built in, so I would recommend using POSTMAN instead to test whether json-server is working properly after doing 'npm run server'.

Losing code snippet in Greetings with store section.

Let's create a simple actions file for our change, message example. But before that, let's create one more item for the store's initial state, counter, and initialize it with a "0" value. So, our store will look like the following:

//store.js 
import Vue from 'vue' 
import Vuex from 'vuex' 
import { CHANGE_MSG, INCREMENT_COUNTER } from './mutation_types' 

Vue.use(Vuex) 

const state = { 
 message: 'Hello Vue!', 
 counter: 0 
} 

const mutations = { 
 [CHANGE_MSG](state, msg) { 
   state.message = msg 
 }, 
 [INCREMENT_COUNTER](state) { 
   state.counter ++; 
 } 
} 

export default new Vuex.Store({ 
 state, 
 mutations 
}) 

Actually it should be as follow, the code hosts on Github.com is correct.

import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters' //should add 
import actions from './actions' //shoud add
import { CHANGE_MSG, INCREMENT_COUNTER } from './mutation_types'

Vue.use(Vuex)

const state = {
  msg: 'Hello Vue!',
  counter: 0
}

const mutations = {
  [CHANGE_MSG](state, msg) {
    state.msg = msg
  },
  [INCREMENT_COUNTER](state) {
    state.counter ++
  }
}

export default new Vuex.Store({
  state, mutations, getters, actions//should add getters and actions.
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.