在写项目的时候发现layui直接渲染是没用的,详情看官方文档使用,Layui文档

 $(document).ready(function () {
    $.ajax({
    type: "get",
    url: "/admin/node/get_node_protocol",
    data: { usernames: $.cookie('username'), token: $.cookie('token')},
    dataType: "json",
    success: function (response) {
        var data  = response['data'];
        
        
        if(response.code == 200){
            var addData = '';
            var data  = response['data'];
            for(var i = 0 ; i < data.length ; i++){
            addData += "<option value="+data[i].node_protocol_id+">"+data[i].node_protocol_en_name+"</option>";//拼接
            $('select#listdata').html(addData);
            }

            var form = layui.form;
            form.render('select');//重点:重新渲染select
        }
    }
});
Last modification:May 20th, 2019 at 03:25 pm
If you think my article is useful to you, please feel free to appreciate