![](/img/trans.png)
[英]How can I conditionally redirect to a page after the axios response in react?
[英]Axios - how can I conditionally append fields
我有此Axios補丁程序,但如果超鏈接列不為null,我只想包括后三個。 我怎樣才能做到這一點?
謝謝,
米克
axios.patch('/' + self.table + '/' + self.rowId,{
name: self.name,
SQL:self.SQL,
area_id:self.area_id,
report_type_id:self.report_type_id,
mode:self.mode,
database_connection_id:self.database_connection_id,
pagination: self.pagination,
show_export_buttons : self.show_export_buttons,
filters : self.filters,
description : self.description,
category_id : self.category_id,
hyperlink_column : self.hyperlink_column,
linked_report : self.linked_report,
link_parameter : self.link_parameter,
由於從外觀上看,它看起來像第二個參數是一個對象,因此一種實現方式是調用一個函數作為第二個參數,並將數據作為參數傳遞給self
。 然后,該函數將檢查self.hyperlink_column
存在,然后相應地返回一個對象。 像這樣
PS:這是使用閉包完成的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.