[solved] which file is the Mini Program global object of mpvue configured in?

Business background

mpvue developer Mini Program
wants to get global globalData

on the page.

perplexed

it is not directly stated in the official documentation
that this attribute is not found in App.vue and main.js files in the src directory.
now I"m out of my mind, thinking about Rest. So now I don"t know how to solve it with my own ability

question

Please tell me ~ Thank you

Mar.02,2021

this is a pseudo requirement
what I originally meant was:

  • define some global variables and methods in the global object
  • then share this data on various sub-pages to manipulate

in fact, in each sub-page, the direct operation is the same by getting the global object. There is no need to set..


at the entry main.js, after mounting the node, add one more thing:
Vue.prototype.globalData = getApp (). GlobalData.
this way you can get global variables for each instantiated object.
the second way is to use vuex

Menu