layui form里的select元素动态赋值无效

需要重新更新渲染下select下拉框

使用 form.render('select');

                      $.ajax({
                            url:url,
                            contentType:"application/json;charset=UTF-8",
                            type:'GET',
                            async:false,
                            success: function (res) {

                                let data=res.results,
                                    str1=`<option value="">请选择资产</option>`;
                                data.map((item,index)=>{
                                    console.log(item)
                                    str1+=`<option value="${item.id}">${item.name}</option>`
                                })
                                $("#quiz2").html(str1);
                                console.log(data);
                                form.render('select');
                            },
                            beforeSend:function(xhr){//
                                xhr.setRequestHeader("Authorization",iotAuthorization);
                                xhr.setRequestHeader("X-SiteWhere-Tenant",iotTenant);
                            }
                        });

 

posted @ 2021-07-29 18:43  虚无——缥缈  阅读(580)  评论(0编辑  收藏  举报