Use the eval() function in vue

eval():

Function: Its function is to parse the corresponding string into js code and run it (parse the json string into a JSON object);

Features: it is a global function;

Disadvantages: 1> The variables declared inside the function are all global variables, and the declared variables will not be promoted;

2> Consumes performance, executes twice, once parses into js statement, once executes js code;

Example:

Functions defined by themselves, through dynamic assignment

xTable${index}`

The above code returns a string and cannot call the defined method

let a=[`xTable${index}`];
      console.log('a:', eval(`${a[0]}.value`))

Add the eval() function to call

Guess you like

Origin blog.csdn.net/qq_27318177/article/details/119204453
Recommended