vuex - modal的实现 =>从入门到放弃(三)
2017-07-19 15:06
543 查看
本节讲点的重点是modal的回调函数
参照(一)的方法吧three.modal.vue弹出的功能实现的
基本的操作介绍:点击第三按钮,弹出modal,然后点击modal里面的按钮,执行一次的回调事件(本例子回调 页面count的 +1 操作)
three.modal.vue
参照(一)的方法吧three.modal.vue弹出的功能实现的
基本的操作介绍:点击第三按钮,弹出modal,然后点击modal里面的按钮,执行一次的回调事件(本例子回调 页面count的 +1 操作)
three.modal.vue
<template> <div id="vuex"> <button class="first-modal" @click="firstClick">打开modal</button> <button class="second-modal" @click="secondClick">点击btn传数据到modal上面去</button> <button class="three-modal" @click="threeClick">回调函数</button> <h1 class="h1">{{count}}</h1> </div> </template> <script> export default { name: 'vuexdemo', data(){ return { show:'我是页面传递过来的数据', count:1, } }, methods: { add(){ this.count++; }, firstClick(){ this.$store.dispatch('toggleModal', { name: 'firstmodal', status: true }) }, secondClick(){ this.$store.dispatch('toggleModal', { name: 'secondmodal', status: true, data:this.show, }) }, threeClick(){ this.$store.dispatch('toggleModal', { name: 'threemodal', status: true, callback:this.add(), //页面的回调操作 }) } } } </script>
相关文章推荐
- vuex - modal的实现 =>从入门到放弃(一)
- Android开发之入门基础篇-->拨号器的四种实现方式
- JavaScript从入门到放弃(3)-对象的不同创建方法-实现真正的面向对象
- OpenStack入门修炼之实战-->实现阿里云ESC多FLAT网络(21)
- C++入门笔记<实现复数类>
- Web从入门到放弃<6>
- android水波纹涟漪效果的实现<入门+初步提高>
- Web从入门到放弃<3>
- html从入门到放弃(7)-入门标签:块元素与内联元素<div/>和<span/>
- Web从入门到放弃<1>
- Web从入门到放弃<4>
- html从入门到放弃(3)-链接<a/>
- JavaWeb从入门到放弃(9)-实现一个客户端上传文件到服务端
- MyBatis从入门到放弃一:从SqlSession实现增删改查
- Vuex,从入门到放弃
- Web从入门到放弃<7>
- 算法入门->插入排序->C/C++ 语言实现
- iOS AutoLayout阅读笔记4------->AutoLayout入门动画示例(纯IB实现)
- Unity3D从入门到放弃(七) ----DoTween的实现
- CMake入门学习+实战<四> 使用外部共享库和头文件+实战:使用CLion调用zlib静态库实现pdf flatedecode解码