Set global variables or data methods in vue, vue global variables
Example:
Const MyPlugin = {// the install method is required. // it contains two parameters: Vue constructor and an optional option object install (Vue, options) {Vue. prototype. test = "test"; Vue. prototype. wechat = "my wechat! ";}}; Export default MyPlugin
This method can start a file separately. After the file is introduced to the required page, you can use the vue instance to obtain the corresponding data, as shown in the following use, the same method is used to retrieve data from each module.
Import MyPligin from './**/api'; // introduce the global variable Vue. use (MyPligin );
The above method for setting global variables or data in vue is all the content shared by Alibaba Cloud xiaobian. I hope you can give us a reference and support for the customer's home.