不废话直接上代码
layui.use([‘form‘], function () { var form = layui.form; form.on(‘select(quiz1)‘, function (data) {//监听quiz1 console.log(data) var url=iotIpport+"/ccpiot/api/assets/modules/"+ data.value+"/assets" $.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)=>{ 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); } }); }); });