I have an input field that looks like this:
<input placeholder="Card Number" name="cc-number" data-stripe="number" class="add-card-form__card-number input" value="">
I'd like to do something like this:
onFocus (e) {
const { 'data-stripe': name, value } = e.target
// do something with `name` and `value`
}
I know I can use e.target.getAttribute('data-stripe')
, but that defeats the purpose of destructuring. Any ideas how to do this?
Here it says exactly what I'm doing. How to destructure object properties with key names that are invalid variable names?