我在后端有一个API来返回AlpacaJS表单的完整json (模式和选项)。响应的内容类型是application/json。以下是一个样本答复,
{
"options": {
"fields": {
"students": {
"items": {
"type": "tablerow"
},
"type": "table"
}
},
"form": {
"buttons": {
"submit": {
"click": "function(){alert(\"sample\");}"
}
}
}
},
"schema": {
"properties": {
"students": {
"items": {
"properties": {
"name": {
"required": true,
"title": "Name",
"type": "string"
},
"contact-number": {
"title": "Age",
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
}单击Submit按钮时,会在浏览器控制台中得到以下错误:
Uncaught TypeError: t.call is not a function
我认为问题在于,在响应的下面一节中,函数被视为字符串。
"form": {
"buttons": {
"submit": {
"click": "function(){alert(\"sample\");}"
}
}
}AlpacaJS中是否有从后端发送javascript函数的方法,或者是否有方法将函数字符串转换为前端的javascript函数?
https://stackoverflow.com/questions/48722807
复制相似问题