Suppose we define a global method in main. JS
//main.js
app.config.globalProperties.$hello = name => {
console.log('hello ' + name)
}
Call this method in other pages.
//other.js
import { getCurrentInstance } from "vue";
const { appContext } = getCurrentInstance();
const callHello = ()=>{
appContext.config.globalProperties.$hello('jay');
}
callHello()
//'hello jay'
Read More:
- Apache Groovy——java.lang.NoSuchMethodError: x.x.x: method <init>()V not found
- Win10 (1703) app store download app prompt error code 0x80d0000a
- The software of Final Cut Pro x 10.5 failed to open, and it flashed back directly.
- It is invalid to submit the content directly after pasting it on the mobile terminal of Vue HTML5 editor
- Vue error: no postcss config found solution
- RuntimeError: Expected hidden[0] size (x, x, x), got(x, x, x)
- Win10 app store error code: 0x80072efd
- ERROR Invalid options in vue.config.js: “plugins“ is not allowed
- When starting Vue project: cannot find module ‘webpack cli/bin/config yargs’ error [How to Fix]
- VUE Error: Cannot find module ‘webpack/bin/config-yargs’
- Vue3. X reports an error using vantui. Failed to resolve component: Van-**-**
- [Solved] emulator: glteximage2d: got err pre 🙁 0x502 internal 0x1908 format 0x1908 type 0x1401
- CLP: error: getaddrinfo enotfound http://x.x.x.x/
- The Vue parent component uses ref to call the sub component method and reports an error
- ArcGIS Earth 1.7 beta installation method-solve the 0X80070057.DirectX device creation failed problem
- Error code 1 error resolution (NPX create react app my app execution reports an error)
- module ‘win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9‘ has no attribute ‘CLSIDToClassMa
- Module not found: Error: Can’t resolve ‘./$$_gendir/app/app.module.ngfactory’
- Vue agent reports an Error 404 nginx configuration method
- Vue calculates attributes and passes parameters to the computed method