[Nuxt] Setup a "Hello World" Server-Rendered Vue.js Application with the Vue-CLI and Nuxt
2017-07-24 15:33
676 查看
Install:
Init project:
Run:
Create a index.js file inside store folder:
Display the counter inside pages/index.vue:
mapState: return a state tree object.
We can also write:
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 }) }
相关文章推荐
- [Vue] Build Vue.js Apps with the Vue-CLI and Nuxt.js
- [Vue] Create Vue.js Layout and Navigation with Nuxt.js
- The GNU build system体验教程:Hello world example with Autoconf and Automake
- [Nuxt] Update Vuex State with Mutations and MapMutations in Vue.js
- [Nuxt] Add Arrays of Data to the Vuex Store and Display Them in Vue.js Templates
- [Nuxt] Navigate with nuxt-link and Customize isClient Behavior in Nuxt and Vue.js
- [Vue] Preload Data using Promises with Vue.js and Nuxt.js
- Spring 3 mvc hello world application with maven and jstl
- Java IDL: The "Hello World" Example Using the POA, a persistent server, and a persistent naming service
- [React] Theme your application with styled-components and "ThemeProvider"
- The server method '' failed with the following error:" .... and no error description
- Error applying site theme: A theme with the name "Jet 1011" and version already exists on the server.
- Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details
- Vue报错——the "scope" attribute for scoped slots have been deprecated and replaced by "slot-scope"
- [Vue] Update Attributes, Classes and Styles in Vue.js with v-bind
- Server Error in '/' Application. Access to the Path Is Denied" error message appears
- The Java IDL Development Process and the Hello World Tutorial
- FW:What you can and can't do with the MessageBox Database server
- Setup failed to configure the server. Refer to the server error logs and setup error logs for more i
- Failed to apply package protection with error 0xC0014061 "The protection level, ServerStorage, cannot be used when savin