Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

call a function of another component vue

    ....
    mounted() {
        this.$root.$on('component1', () => {
            // your code goes here
            this.c1method()
        }
    }
Comment

how to call function from another component in vue js

Vue.component('component1', {
  methods: {
    c1method: function(){
     alert('this is c1method')
    },
  }
})
Vue.component('component2', {
  methods: {
    c2method: function(){
     component('component1').c1method()//like this
    },
  }
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript get date value from input 
Javascript :: javascript filter example 
Javascript :: javascript case insensitive regex 
Javascript :: e.target.value with number 
Javascript :: array sort 
Javascript :: codesandbox react emet 
Javascript :: angular 9 features 
Javascript :: react-scripts not found 
Javascript :: javascript no decimal places 
Javascript :: console log like a pro 
Javascript :: how to turn a string into an array javascript 
Javascript :: underscore.js 
Javascript :: find function in javascript 
Javascript :: javascript document get by attribute 
Javascript :: filter properties from object javascript 
Javascript :: chart.js 
Javascript :: best way to filter table in angular 
Javascript :: javascript pass array by value 
Javascript :: how to remove an element from an array javascript 
Javascript :: Find the maximum number of an array js 
Javascript :: requestanimationframe in javascript 
Javascript :: upload file in node 
Javascript :: set active element javascript 
Javascript :: Javascript: 
Javascript :: javascript async await returns undefined 
Javascript :: browser support fetch api 
Javascript :: client.login discord.js 
Javascript :: convert javascript date into excel date 
Javascript :: run promise one by one 
Javascript :: declaring variable react hooks 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =