javascript - How to specify a function function in the data attribute of html5?
学习ing
学习ing 2017-06-24 09:43:53
0
6
1047

Can I specify a function function in the data-* attribute?

For example, if I write like this, I will get an error formatter is not a function:

<th  data-formatter="test3(value, row, index)">field_name_cn</th>
学习ing
学习ing

reply all(6)
迷茫

Eval is enough, but I think your way of solving the problem is unreasonable. Why not tell us your needs and see if there is a good solution

阿神

is not function:is string

typecho

No.data-attribute is still an attribute, its value is just a string.

The function can be converted into a string, but of course it loses the characteristics of the function

阿神

Speaking of which, you can eval and execute the string as a function code

代言

But if you use vue or react framework, you can solve this problem. But this is pure html, it won’t work

黄舟

Curious what do you want to do?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template