Skip to content

Commit d17631d

Browse files
committed
fix: 优化文档
1 parent a7d69cb commit d17631d

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

docs/quark-go/resources.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -521,34 +521,30 @@ SetOptions([]*selectfield.Option{
521521
``` go
522522
import ("github.com/quarkcms/quark-go/pkg/component/admin/form/fields/selectfield")
523523

524-
// 下拉框联动
525-
Field::selects([
526-
// 下拉框联动
524+
field.Selects([]interface{}{
527525
field.Select("province", "").
528-
SetOptions([]*selectfield.Option{
529-
{Value: 1, Label: "北京"},
530-
{Value: 2, Label: "天津"},
531-
{Value: 3, Label: "河北省"},
532-
}).SetLoad("city","/api/admin/area/cities"),
533-
534-
//
535-
Field::select("city", ""),
536-
]);
526+
SetOptions([]*selectfield.Option{
527+
{Value: 1, Label: "北京"},
528+
{Value: 2, Label: "天津"},
529+
{Value: 3, Label: "河北省"},
530+
}).SetLoad("city", "/api/admin/test/cities"),
531+
field.Select("city", ""),
532+
}),
537533
```
538534

539535
#### ```/api/admin/area/cities```接口返回数据格式
540536

541537
``` go
542-
return []map[string]interface{}{
543-
{
544-
"label":"石家庄",
545-
"value":10,
546-
},
547-
{
548-
"label":"唐山",
549-
"value":11,
550-
},
551-
}
538+
return ctx.JSONOk("获取成功", "", []map[string]interface{}{
539+
{
540+
"label": "石家庄",
541+
"value": 10,
542+
},
543+
{
544+
"label": "唐山",
545+
"value": 11,
546+
},
547+
})
552548
```
553549

554550
### Date
@@ -692,7 +688,7 @@ field.Cascader("address", "地址").SetOptions(options1).SetApi("/api/admin/area
692688
``` go
693689
import ("github.com/quarkcms/quark-go/pkg/component/admin/form/fields/cascader")
694690

695-
return []*cascader.Option{
691+
return ctx.JSONOk("获取成功", "", []*cascader.Option{
696692
{
697693
Value :"zhejiang",
698694
Label:"Zhejiang",
@@ -703,7 +699,7 @@ return []*cascader.Option{
703699
Label:"hebei",
704700
IsLeaf:false,
705701
},
706-
}
702+
})
707703
```
708704

709705
### Search
@@ -734,11 +730,11 @@ field.Search("category_id", "分类").SetApi("/api/category/suggest")
734730

735731
#### 接口返回数据
736732
``` go
737-
return []*search.Option{
733+
return ctx.JSONOk("获取成功", "", []*search.Option{
738734
{Value: 1, Label: "新闻"},
739735
{Value: 2, Label: "音乐"},
740736
{Value: 3, Label: "体育"},
741-
}
737+
})
742738
```
743739

744740
### Tree

0 commit comments

Comments
 (0)