Giter Club home page Giter Club logo

qiankun-demo's Introduction

qiankun框架的简单使用

demo介绍

父子应用都是使用的 vue 框架,且路由模式都是 hash 模式。

跳转方式

  • 父应用跳转父应用:正常使用vue-router进行跳转
  • 父以用跳转子应用:添加子应用对应的路由前缀进行跳转, 推荐用path方式进行跳转
  • 子应用跳转子应用:
    • 使用path的方式进行跳转,不加/
    • 使用path的方式进行跳转,补充子应用前缀(感觉这种方式比较呆)
  • 子应用跳转父应用:正常使用vue-router进行跳转

父子应用间的通信

使用 vuex 进行状态管理,将需要通信的数据与 setGlobalState 方法挂载到 state 上面。

import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		qiankunData: {},
		qiankunSetGlobalStateFunc: () => {},
	},
	getters: {},
	mutations: {
		setQiankunData(state, data) {
			state.qiankunData = data
		},
		initQiankunSetGlobalStateFunc(state, func) {
			state.qiankunSetGlobalStateFunc = func
		},
	},
	actions: {
		noticeQiankun({ commit, state }, data) {
			commit('setQiankunData', data)
			state.qiankunSetGlobalStateFunc(state.qiankunData)
		},
	},
	modules: {},
})

qiankun-demo's People

Contributors

1249682741 avatar lipeiquan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.