Go off work, play the piano

Vuex principle

Vuex responsive principle —— corresponds to the Dep object operation in vue.js; (dep notifies all watchers of updates when data changes;)

Each VUE instance corresponds to a Watcher, and these Watcher are also managed in the DEP;

Once reactive (data update) occurs, deP notifies all the watcher below to update;

Here’s a simplified version of vuex:

VueRouter principle

Core: Different functions implemented by history are determined by mode. Different modes correspond to different history calls at the bottom level. But in both cases, the window provides location for browser event listening; Vue-route encapsulates native events.

** Take HashHistory **

This. History is initialized when the ue-router is instantiated. Different modes correspond to different histories (e.g., hash, corresponding to instance hashHistory).

Take HashHistory, the push method of vue-Router

The essence is to call the window.location.hash =path method

Route listening is implemented with hash corresponding event listening :(browser event triggered by relevant operation)