alibaba / lowcode-engine

An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系
https://lowcode-engine.cn
MIT License
14.64k stars 2.55k forks source link

子组件执行父组件方法 报错 Uncaught TypeError: Cannot read properties of undefined (reading 'apply') #700

Closed dzlhk closed 2 years ago

dzlhk commented 2 years ago

Describe the bug (required) / 详细描述 bug(必填)

1.拖拽区块片段到 页面中, const dragTarget = { type: 'nodedata', data: currentNodeData, }; 2.预览页面执行按钮, 3.提示错误

image

4.核心出错代码 ,子组件中按钮绑定了 JSFunction function(){this.onClick_new(this,Array.prototype.slice.call(arguments).concat([])) }

currentNodeData 代码如下 `

{ "componentName": "Block", "id": "node_dockcviv8fo1", "props": { "ref": "outerView", "style": { "height": "100%" } }, "fileName": "/", "dataSource": { "list": [ { "type": "fetch", "isInit": true, "options": { "params": {}, "method": "GET", "isCors": true, "timeout": 5000, "headers": {}, "uri": "mock/info.json" }, "id": "info" } ] }, "state": { "text": { "type": "JSExpression", "value": "\"outer\"" }, "isShahha": { "type": "JSExpression", "value": "false" } }, "css": "body {\n font-size: 12px;\n}\n\n.button {\n width: 100px;\n color: #ff00ff\n}", "lifeCycles": { "componentDidMount": { "type": "JSFunction", "value": "function componentDidMount() {\n console.log('did mount');\n}" }, "componentWillUnmount": { "type": "JSFunction", "value": "function componentWillUnmount() {\n console.log('will unmount');\n}" } }, "methods": { "testFunc": { "type": "JSFunction", "value": "function testFunc() {\n console.log('test func');\n}" }, "onClick": { "type": "JSFunction", "value": "function onClick() {\n this.setState({\n isShowDialog: true\n });\n}" }, "closeDialog": { "type": "JSFunction", "value": "function closeDialog() {\n this.setState({\n isShowDialog: false\n });\n}" }, "onClick_new": { "type": "JSFunction", "value": "function onClick_new() {\n console.log('测试啦啦啦啦');\n alert('执行成功啦');\n}" } }, "originCode": "class LowcodeComponent extends Component {\n state = {\n \"text\": \"outer\",\n \"isShowDialog\": false\n }\n componentDidMount() {\n console.log('did mount');\n }\n componentWillUnmount() {\n console.log('will unmount');\n }\n testFunc() {\n console.log('test func');\n }\n onClick() {\n this.setState({\n isShowDialog: true\n })\n }\n closeDialog() {\n this.setState({\n isShowDialog: false\n })\n }\n\n\tonClick_new(){\n console.log('测试啦啦啦啦')\n alert('执行成功啦')\n\t}\n}", "hidden": false, "title": "", "isLocked": false, "condition": true, "conditionGroup": "", "children": [ { "componentName": "Button", "id": "node_ocl4nzxf8y3", "props": { "prefix": "next-", "type": "primary", "size": "medium", "htmlType": "button", "component": "button", "children": "取消", "iconSize": "xxs", "ghost": false, "loading": false, "text": false, "warning": false, "disabled": false, "__events": { "eventDataList": [ { "type": "componentEvent", "name": "onClick", "relatedEventName": "onClick_new" } ], "eventList": [ { "name": "onClick", "description": "点击按钮的回调\n@param {Object} e Event Object", "disabled": true }, { "name": "onMouseUp", "disabled": false } ] }, "onClick": { "type": "JSFunction", "value": "function(){this.onClick_new(this,Array.prototype.slice.call(arguments).concat([])) }" } }, "hidden": false, "title": "", "isLocked": false, "condition": true, "conditionGroup": "" } ] }`

github-actions[bot] commented 2 years ago

你好 @dzlhk,由于缺乏必要的信息(如 bug 重现步骤、引擎版本信息 等),无法定位问题,请按照 issue bug 模板 补全信息。

JackLian commented 2 years ago

麻烦给一个demo或者复现步骤

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 2 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 10 days with no activity.