美文网首页
vuex数据传递

vuex数据传递

作者: 落花夕拾 | 来源:发表于2020-06-08 16:55 被阅读0次

1、主页

//aiot.vue
import qdExceptionsCountry from './component/country-city-view/exceptions.vue'
//内容组件,并拥有点击弹框的click操作 
  <qd-exceptions-country />
//弹框组件
import qdExceptionsCountry from './component/country-city-view/exceptions.vue'


   <!-- 更多 弹框 -->
    <div v-if="rank == 'community'">
      <qd-more-exceptions />
      <qd-more-warning />
      <qd-more-workorder />
    </div>
    <div v-else>
      <qd-more-exceptions-country />
      <qd-more-warning-country />
      <qd-more-workorder-country />
    </div>

2、内容页


//exceptions.vue

   <div class="wrap-more" @click="showMore">更多<i class="more" /></div>

import { mapState, mapGetters, mapMutations } from 'vuex'
  methods: {
    ...mapMutations(['showExceptions']),
    showMore() {
      this.showExceptions()
    },
}

3、vuex

//index.js
import Vuex from 'vuex'
import Vue from 'vue'
const store = new Vuex.Store({

state:{
    showMoreWorkorder: false,
},
getters: {
    isDim: state => {
      return state.showMoreExceptions || state.showMoreWorkorder || state.showMoreWarning
    },
},
mutations:{
 showWorkorder(state) {
      state.showMoreWorkorder = true
    },
},
action:{

}
})

4showMoreExceptions

//moreExceptions.vue

<div class="qdDialog flex-center" @click.self="hide" v-show="showMoreExceptions">
</div>

//vuex,computed,watch结合使用
  computed: {
    ...mapState(['showMoreExceptions', 'rank']),//获取弹框弹框状态标识
    ...mapGetters(['projectId']),
  },
   watch: { //监听当弹框显示时,查询其他数据
    showMoreExceptions(val) {
      if(val){
        this.remark = ''
        this.selectedOptions = [],
        this.showConfirm = false
        this.getData()
        this.getMonthData()
        this.getListData()
        this.getOrderType()
      }
    }
  }

相关文章

  • Vuex

    Vuex简介: 由于使用propes传递数据太麻烦,所以使用vuex进行状态管理。不能直接修改vuex中的数据,只...

  • Vue中使用vuex在页面刷新之后状态不丢失的解决方法

    由于vue自身特性的原因,vuex中的数据在页面刷新之后其中的数据会初始化,这就导致组件之间通过vuex传递的数据...

  • vuex数据传递

    1、主页 2、内容页 3、vuex 4showMoreExceptions

  • Vue-day-07(vuex基础使用)

    1.vuex基础 1.1 vuex概述 1 问题 之前共享数据,是通过以上方式以上方式,只适用于小范围内传递数据 ...

  • vuex基础

    vuex介绍 需求:父子组件的传值可以通过props和发布事件来传递,不相关的组件如何传递数据,或者说共用一份数据...

  • VUEX 详解

    为什么使用vuex 在中大型应用中,应用的各个组件间需要进行数据传递,使用传统方式繁琐且不可控 Vuex 为所有组...

  • Vuex

    关于VueX Vuex 是一个专为 Vue.js 应用程序开发的状态管理工具大型项目使用为解决组件之间传递数据 之...

  • vue-ts

    vue-typescript 组件之间传递;vuex;

  • Vuex的工作原理

    1.为什么要用vuex?对于组件间共享的数据、或是需要通过props深层传递的一些数据,以前的通信方式会导致数据流...

  • $attrs、$listeners在Vue中的使用

    在多级组件嵌套需要传递数据时,通常会想到的方法是使用vuex或者bus传值,又或者事件触发传值,但是如果仅仅是传递...

网友评论

      本文标题:vuex数据传递

      本文链接:https://www.haomeiwen.com/subject/mpmrtktx.html