[Vuejs]-Call Vue 3 function by it's name in string variable

0👍

What you have done here is assigned a string to the variable functionName. Though your post lacks some context, if you are just trying to call one function from another, it would look like this:

<script setup>

function myFunction(params){};
function myOtherFunction(){
   myFunction()
};

</script>

Or more like how you have it written. This is valid syntax as well:

let myFunction = (params) => {};
let myOtherFunction = (params) => {
  myFunction(params);
}

0👍

Define your function as property inside a literal object then call it using brackets:

const funcs={
  myFunction:function(param){
   ///
  }
}

// and now you could call it like 
funcs["myFunction"](yourArg)

Leave a comment