Vuex demo
2024-10-20 08:29:45
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title> </head>
<body>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vuex@3.0.1/dist/vuex.js"></script>
<div id="app">
<p>{{count}}
<button @click="inc">+</button>
<button @click="dec">-</button>
</p>
</div>
<script> const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
inc: state => state.count++,
dec: state => state.count--
}
}) const app = new Vue({
el: '#app',
computed: {
count () {
return store.state.count
}
},
methods: {
inc () {
store.commit('inc')
},
dec () {
store.commit('dec')
}
}
})
</script> </body>
</html>
最新文章
- 网页日历显示控件calendar3.1
- lintcode 最长上升连续子序列 II(二维最长上升连续序列)
- 关于session和token
- jsp学习笔记一
- C#注意事项及错误处理
- Python学习(1)安装Python
- Android Service 生命周期和使用注意项
- 【deep learning学习笔记】注释yusugomori的LR代码 --- 模型测试
- PHP中GD库安装
- hibernate中Query的list和iterator区别
- org.springframework.web.filter.DelegatingFilterProxy的作用
- Linux- 常用命令, Vim编辑器操作
- linux执行jmeter脚本解决响应数据为空
- 重写TreeView模板来实现数据分层展示(一)
- [No0000127]WCF安全体系netTCPBinding绑定
- spring管理hibernate,mybatis,一级缓存失效原因
- $()与document.getElementById
- <;浪潮之巅>;读书笔记
- HDU4388:Stone Game II(博弈+思维)
- jquery 获取绑定事件
热门文章
- 关闭chrome浏览器的input香蕉黄背景
- luoguP1040 区间DP(记忆化 加分二叉树
- vue-cli脚手架每行注释--摘抄
- 视音频数据处理入门:RGB、YUV像素数据处理【转】
- hdu3338 / 方格横纵和问题终极版,最大流斩
- 富文本ZSSRichTextEditor之趟坑集锦
- BZOJ 3309 莫比乌斯反演
- django删除表重建&;修改用户密码&;base64加密解密字符串&;ps aux参数说明&;各种Error例子
- CDOJ 3 BiliBili, ACFun… And More! 模拟
- OAuth 2.0 in Web API #Reprinted