mxml中動態生成元件

2021-08-24 22:50:01 字數 2036 閱讀 3484

客戶那邊的api 返回值如下

index1

rush

ydropdown

none110

01index2

policy_sym_num_mod

ytextbox

none2p

1012

2.....

public function genlabel(text:string):label

public function gendatefield(idname:string,val:string=null):datefield

public function gencombox(idname:string,ac:arraycollection,index:int=-1):combobox

public function genvalidator(component:displayobject,str:string,msg:string):regexpvalidator

//model中的校驗規則

public var validaterule:object=','agent code entered is invalid. ok.'],

index8:['[a-za-z]','uw initials entered is invalid. ok'],

index10:['[0-9]','customer number entered is invalid. ok'],

symbol:['[a-z]','field requires a 3 alpha policy symbol. ok'],

number:['[0-9]','field requires a 7 digit policy number. ok'],

mod:['[0-9]','field requires a 2 digit policy module. ok']

}; public function gentextfield(idname:string,len:int=0,val:string=null):textinput

return t;

}//policy 為初始值

public function genpolicy(policy:string):hboxelse

var hbox:hbox=new hbox();

hbox.addchild(componet);

hbox.addchild(componet1);

hbox.addchild(componet2);

return hbox;

}//遍歷arraycollection中的輸入框預設值

private function findac(ac:arraycollection,val:string):string

return null;

}//遍歷arraycollection中的combobox的selectedindex

private function findtwoac(val:string,ac:arraycollection,ac1:arraycollection):int

}elseelse if(componentinfo.name == "mx.controls::textinput" || componentinfo.name == "mx.controls::datefield")

}}//end for

}//end if

}public function whichbox(arr:array,obj:object,len:int,obj1:object,ac:arraycollection):voidelse

}public function boxview(arr:array,obj:object):void

} catch(e:error)

}注意的問題:

1 為空時設定高度,因為沒有設定高度,動態新增的元件不顯示

2 getchildren,childdescriptors的區別

childdescriptors 特指嵌入的mxml子元件

getchildren指所有的子元件

mxml中動態生成元件

可以參考重新設計的 無需太多的型別判斷 mx.controls combobox mx.controls textinput mx.controls datefield flex mxml中動態生成元件,生成的效果如圖 隨著document type的改變,下面的輸入框,下拉框也改變 客戶那邊的ap...

vue動態生成表單元件vue form maker

vue動態生成表單元件 可以根據資料配置表單 使用的ui庫是iview 在vue裡 一般要用到什麼元件或資料 都得提前宣告 所以要根據資料來生成表單 只能使用vue的render函式 要做這乙個元件 其實並不難 看一下vue官方示例 再找個ui元件庫 差不多就能寫出來 如果對專案有興趣 可以fork...

父元件動態生成,子元件值進行渲染

需求 外邊框 dv border box 3 動態生成,裡面的圖形正確渲染 this.refs.drag draggable 是陣列問題 單個圖形沒問題,多個圖形渲染的時候,vue會將最新生成的component放在陣列末尾,儲存圖形渲染的資料也是陣列 渲染的時候會從陣列中獲取到當前操作的資料 這樣...