我有带有调用单独 JS 文件的选项卡的 React 应用程序。我正在使用 SurveyJS,其中每个调查都有一个完整的按钮。在我的父页面上,我的保存按钮我需要让它调用每个 JS 文件,.onComplete 方法
带有标签的父页面示例
import {Tab, Tabs } from 'react-bootstrap';
import * as Survey from "survey-react";
import "survey-react/survey.css";
import SectionA from './SectionA';
import SectionB from './SectionB';
//Tabs
<Tabs activeKey={this.state.activeTab} onSelect={this.handleSelect}>
<Tab eventKey={1} title="CORE SEC A."><SectionA offline={this.state.online} /></Tab>
<Tab eventKey={2} title="CORE SEC B."><SectionB /></Tab>
...
</Tabs>
//Save button function
const sendSurveyDataAPI = () => {
// need to call all the .onComplete on child pages such as SectionA, SectionB (.js files)
}
子页面示例
var survey = new Survey.Model(json);
// need to call up this from Parent
survey
.onComplete
.add(function (result) {
// don't want this in children
handleSave(result.data);
})