lljj-x / vue-json-schema-form

基于Vue/Vue3,Json Schema 和 ElementUi/antd/iview3/naiveUi 等生成 HTML Form 表单,用于活动编辑器、h5编辑器、cms等数据配置;支持可视化生成表单Schema 。 Generate a form using Vue/Vue3, Json Schema and ElementUi/antdv/iview3/naiveUi
https://form.lljj.me/
Apache License 2.0
2.01k stars 418 forks source link

Get index of array #314

Closed BossHogg97 closed 11 months ago

BossHogg97 commented 11 months ago

Hi, i'm working on Vue 3 with Naive UI. I have an array of object and i would like to retrieve the index number where a field change is detected.

Schema:

{
  "schema": {
    "type": "object",
    "properties": {
      "availablePipe": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "enum": [],
              "enumValues": []
            },
            "total": {
              "type": "number"
            },
            "used": {
              "type": "number"
            }
          }
        }
      }
    }
  }
}

I used the onChange event on ui:schema for detect a possible change on name property inside array. But i don't know how to get the object position where the name property changed.

Thanks

lljj-x commented 11 months ago

Can't get array index

BossHogg97 commented 11 months ago

Ok thanks. I found way to retrieve the index. I used an hidden field called index initialized at startup