Skip to content

page添加其他组件 #2

@littleboss01

Description

@littleboss01

没发现怎么添加curd以外的控件,
后台只有crud会不会太单调了.
尝试写了个函数,来添加自定义json文本

plugins/amis/page.go

func (p *Page) AddBodyByJsonStr(s string) {
	var v interface{}
	err := json.Unmarshal([]byte(s), &v)
	if err != nil {
		println(err.Error())
		return
	}

	switch v := v.(type) {
	case map[string]interface{}:
		// JSON 是对象
		p.AddBody(v)
	case []interface{}:
		// JSON 是数组
		for _, item := range v {
			p.AddBody(item)
		}
	default:
		// 其他类型,可以按需处理或忽略
		println("Unexpected JSON type")
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions