typescript - 推送后打开表单
问题描述
在我推送一个新表单后,如果它是折叠的手风琴列表,我将如何打开该表单?
/** Collapse and expand fields. */
toggleSection(index) {
this.fields[index].open = !this.fields[index].open;
}
/** Adds the first new field in the form. */
firstAddField() {
this.nextPage = false;
var newForm = this.fields.push(this.form);
// this.toggleSection(newForm);
}
当前发生的情况是,当我单击“添加另一个字段”按钮时,firstAddField()
会调用该方法,但是一旦完成,它就会添加折叠的新表单(下图)。我可以单击该项目,然后通过该toggleSection()
方法扩展它,但我希望在我推送一个新项目后运行它。
我对 Typescript 还是很陌生,所以我很抱歉。
解决方案
您期望toggleSection
函数中有索引,因此firstAddField
在添加传递调用toggleSection
函数和最后插入的表单索引之后的函数,如下所示。
firstAddField() {
this.nextPage = false;
var newForm = this.fields.push(this.form);
this.toggleSection(this.fields.length - 1);
}
推荐阅读
- snowflake-cloud-data-platform - 雪花中的出站特权是什么
- r - 使用 dplyr 过滤邮政编码前缀错误的更快方法
- python - Python(多处理)中的“无法分配内存”异常,但可用内存
- react-native - 在 for 循环中等待分派时代码未执行
- sql - 在 oracle 中列出的硬编码项目
- laravel - Laravel 5 & Vue 组件 – 从 URL 中移除 Public
- git - 如何删除我在 3 天前提交的 github 上的提交而不会丢失以后的数据?
- javascript - 将功能作为道具发送给它时反应组件重新渲染
- c++ - C++ 函数可能会根据传递的参数返回不同的向量 - 但我收到编译器警告
- php - 将一个数组缩减为另一个数组