[Vuejs]-I have vue js component which i have those two function i want to pass them into my vue component how can i do this

0👍

You can use methods for your functions.

https://v1.vuejs.org/guide/events.html

In your template:

<div id="example">
  <button v-on:click="greet">Greet</button>
</div>

In your script:

var vm = new Vue({
  el: '#example',
  data: {
    name: 'Vue.js'
  },
  // define methods under the `methods` object
  methods: {
    greet: function (event) {
      // `this` inside methods point to the Vue instance
      alert('Hello ' + this.name + '!')
      // `event` is the native DOM event
      alert(event.target.tagName)
    }
  }
})
// you can invoke methods in JavaScript too
vm.greet() // -> 'Hello Vue.js!'

0👍

i Found The Answer
the Issues Was in (this)

flatten(elements,color){ 

 console.log(elements);

  elements.forEach(function(element)
  {
    console.log(this.shadeColor("fcfcfc", -5))
    if (element.children.length > 0) 
    {
      console.log(element);
      element.color = this.shadeColor(color, -5)
      this.flatten(element.children, element.color)
    }
    element.color = this.shadeColor(color, -5)


  }.bind(this))
  return elements

}

that the answer just i need to bind (this)

Leave a comment