layui使用laytpl模板引擎动态加载下拉框option

html

js

layui.use('laytpl', function(){
    var laytpl = layui.laytpl;
    function queryAllBsChannel(){
        $.ajax({
            url: xxx,
            type: "POST",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(xxx),
            beforeSend: xxx,
            success: function (res) {
                var data = res.info;
                if (data) {
                    var list = {
                        "listChannelType":data
                    }
                    var getTpl = $("#selectChnTypes").get(0).innerHTML;
                    var view = $("#channelType").get(0);
                    laytpl(getTpl).render(list, function (html) {
                        view.innerHTML = html;
                    });
                }
                form.render('select');
            }
        });
    }

}); 

 

你可能感兴趣的:(Layui)