2018-11-23子页面与主页面之间的调用

1.在store中的common.js中增加需要调用的子模块

 viewNames: {
    business: 'business',
  },
const getters = {
 businessViewName: state => state.viewNames.business,
}

2.在主页面中增加,增加动态组件

 

然后需要在后边div中使用v-else来显示默认的首页信息

 

如果页面中同时有多个页面需要跳转,需要添加viewName判断条件,

 

3.添加新增页面的跳转功能,需要调用vuex的dispatch来重设动态组件的标志

 新增

然后在methods中去编写这个方法

  updateBusiness(row){
        this.$store.dispatch('setTabViewName', ['business', 'dealBusiness']);
      },
//参数需要在数组中定义,bussiness(业务标志)需要在1中定义,dealBusiness(需要显示的页面)需要在2中定义

4.在业务标志页面(主页面)中定义子界面

import DealBusiness from './dealBusiness';
 export default {
    name: 'business',
    components: {JSelectOption,DealBusiness,businessTabs},
}

5.获得初始化动态组件标志

import {mapGetters} from 'vuex';
 computed: {
      ...mapGetters({
        viewName: 'businessViewName'
      }),
//其中businessViewName是vuex中getter中定义额变量

6.有来有回,返回的时候,也需要使用vuex中dispatch去切换动态组件

  返回
methods:{
 goBack(){
          this.$store.dispatch('setTabViewName', ['business', 'business']);
        }
}

你可能感兴趣的:(2018-11-23子页面与主页面之间的调用)