Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Vue.js: Understanding its Tools and Ecosystem

You're reading from   Vue.js: Understanding its Tools and Ecosystem Take a crash course in the main concepts and syntax of the Vue.js library

Arrow left icon
Product type Paperback
Published in Nov 2019
Publisher
ISBN-13 9781800206625
Length 194 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Dave Berning Dave Berning
Author Profile Icon Dave Berning
Dave Berning
Backstop Media LLC Backstop Media LLC
Author Profile Icon Backstop Media LLC
Backstop Media LLC
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface
1. Getting Started with Vue.js 2. Scaffolding Projects With Vue CLI 3 FREE CHAPTER 3. Navigation with Vue Router 4. State Management with Vuex 5. Debugging With Vue DevTools 6. Server-Side Rendering with Nuxt.js 7. Static Site Generation with VuePress 8. Mobile App Development with NativeScript for Vue.js 9. Greater Control of JavaScript and Type Casting with TypeScript 10. The Future of Vue.js and Adoption Rates

Installing and Setting Up Vuex

If you did not install Vuex as an option when initializing your project with Vue CLI 3, don’t worry, you’re still able to install and use it. Just install the package via NPM or Yarn.

$ npm install vuex --save
# or
$ yarn add vuex

Let’s create a new file called store.js in your project’s src directory. This file will contain your Vuex store. Your store contains your application’s state (data), it’s actions (run logic and call a mutation), mutations (actually changes the data), getters, and setters.

For your store.js, you will need to import both Vue and Vuex.

store.js

import vue from 'vue';
import vuex from 'vuex';

Next, you need to tell Vue.js to use Vuex as your state management library in your application.

store.js

Vue.use(Vuex);

After that, you need to set up and export a basic store that contains state, actions, and mutations.

store.js

export default new Vuex.Store({
  state: {

  },...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime