[Nuxt] Setup a "Hello World" Server-Rendered Vue.js Application with the Vue-CLI and Nuxt
2024-08-31 19:22:23
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
})
}
最新文章
- vue.js 的学习
- Java设计模式 - 适配器模式
- ELK笔记
- Sublime Text 3开启自动换行
- 地址标记,SpringMVC转发与调用相关知识存档
- php 7 windows redis 扩展
- 开发Android 范的错误
- Java中final变量的初始化方式
- django防止表单数据重复提交
- C++程序设计实践指导1.8求指定范围内的所有素数改写要求实现
- java 基于JDK中的源码总结下String二
- 【有意思的BUG】需要停止的进程
- HDU 2502 月之数(二进制,规律)
- Spring Cloud Consul使用——配置中心
- Ionic -- css
- Python操作MongoDB(PyMongo模块的使用)
- 检验二叉树序列化的合理性 Verify Preorder Serialization of a Binary Tree
- 在Azure DevOps Server (TFS) 中修改团队项目名称
- CSharp程序员学Android开发---2.个人总结的快捷键
- POJ 1252 Euro Efficiency(完全背包, 找零问题, 二次DP)
热门文章
- 小米开源文件管理器MiCodeFileExplorer-源码研究(6)-媒体文件MediaFile和文件类型MimeUtils
- 洛谷 P1400 塔
- Oracle Sqlplus中上下键出现^[[A乱码问题
- IIS下配置SilverLight
- HASH Partitioning--转载
- IIS进程回收 空闲时Net线程未运行
- python路径找类并获取静态字段
- 前端项目中常用es6知识总结 -- Promise逃脱回调地狱
- python处理文件
- Maven搭建hadoop环境报Missing artifact jdk.tools:jdk.tools:jar:1.7