[Vuejs]-In a Vue component, how do you pass the name of an element as a parameter to a function that the element calls?

0👍

You should use a method and not a computed prop if you wish to pass params to it.
Something like this:

<path name="New York" :class="getPathClass(name)" />

Note: do not use this in a template.

...
methods: {
  getPathClass(pathName) {

  }
}

0👍

Nope. Computed properties are just like that: computed. They do not receive any parameters. What you are looking for are functions that will receive parameters:

methods: {
  getClasses: (name) => {
    // do funny things with name here
  }
}

Another option would be to return a computed property with everything you need in an object. Let’s say that this.name can be aaa, bbb and ccc. You could return from computeClass an object with the following keys:

computed: {
  computeClass: () => {
    // do funny things here 
    return {
      aaa: ...,
      bbb: ...,
      ccc: ...
    }
  }
}

Leave a comment