Communication between different interfaces of vue

Common component: there is a method to call the interface in bar.vue
.
methods: {wishSign () {}}

Public template: cn.vue
bar.vue
import VMbar from"~ / components/base/bar";

is called globally.

Interface: datail.vue
requirements: I think how to trigger a method in bar.vue in a click event in datail.vue. I can"t get the methods in bar.vue with ref. Mainly in the public template: cn.vue is called globally. I can"t get the methods in bar.vue directly. How to call the wishSign method in datail.

Apr.07,2021

this method of calling is not recommended. This way of calling is difficult for others to understand, debug and modify.

the recommended approach is to manage data through parent-child component communication or global store, and data changes to trigger method calls .


there are two ways:

< H2 > 1. Put global components in a global environment, for example: < / H2 >
  

vuex is recommended

Menu