标签:write ted start setup tree put server ati display
Install:
npm install -g vue-cli
Init project:
vue init nuxt/starter .
Run:
npm run dev
Create a index.js file inside store folder:
import Vuex from ‘vuex‘ const store = () => new Vuex.Store({ state: { counter: 0 } }) export default store
Display the counter inside pages/index.vue:
<template> <div> Counter: {{counter}} </div> </template> <script> import { mapState } from ‘vuex‘ export default { computed: mapState({ counter: (state) => state.counter }) } </script>
mapState: return a state tree object.
We can also write:
computed: { ...mapState({ counter: (state) => state.counter }) }
[Nuxt] Setup a "Hello World" Server-Rendered Vue.js Application with the Vue-CLI and Nuxt
标签:write ted start setup tree put server ati display
原文地址:http://www.cnblogs.com/Answer1215/p/7229195.html