A
A
antimodern2019-02-25 18:52:39
Vue.js
antimodern, 2019-02-25 18:52:39

How to safely execute a string passed from a prop?

From one component I need to pass to another parameterease

<animate-me ease="Elastic.easeOut.config(1, 0.75)" />

In the component, I need to use this props. The problem is that it is passed as a string
{
  ease: this.ease
}

Accordingly, this does not work, because Elastic.easeOut.config(1, 0.75)it is not performed. How to proceed? evalor are there other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-02-25
@0xD34F Vue.js

You don't need to do anything, vue will do everything for you. Bind the parameter dynamically (just make sure the Elastic object is available as a property of the component):
:ease="Elastic.easeOut.config(1, 0.75)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question