I have below method in vuejs
methods: {
show () {
}
}
In this show() method often I would like to pass parameter, often I would not like to pass parameter when I'll call it HTML. Like show (obj) and show ()
How can I do that ?
Thanks
methods: {
show (obj) {
if(obj) {
// code to be executed if obj was passed
} else {
// code to be executed if no obj was passed
}
// code to be executed regardless
}
}
You could also set a optional value by using a function parameter default value. See this vuejs example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With