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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bea463-319dd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bea463-319dd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?