当前位置: 首页 > 编程日记 > 正文

在ASP.NET MVC下实现树形导航菜单


在需要处理很多分类以及导航的时候,树形导航菜单就比较适合。例如在汽车之家上:

1

页面主要分两部分,左边是导航菜单,右边显示对应的内容。现在,我们就在ASP.NET MVC 4 下临摹一个,如下:

2

实现的效果包括:
1、点击导航菜单上的品牌,左侧显示该品牌下的所有车型。
2、点击导航菜单上的车系,左侧显示该车系下的所有车型。
3、点击左侧上方的字母导航,锚点跳到导航菜单的对应部分。
4、页面加载完毕,显示所有品牌和车系,即树形导航完全展开。
5、点击导航菜单上的品牌,收缩或展开对应的车系,收缩时,品牌前面图标为+号,展开时,品牌前面的图片为-号。
......

源码部分,在这里。

思路呢?

页面分成左右2部分,使用Bootstrap轻松实现:

<div class="row">
    <div class="col-md-2 col-lg-2 col-sm-2">
    </div>
    <div class="col-md-10 col-lg-10 col-sm-10">
    </div>
</div>

左侧最上方的字母导航,被放在一个div中,页面加载的时候向控制器动态请求。

品牌上方的字母归类,比如奥迪上方的字母A,实际上是一个div。

品牌和车系放在了ul中,比如奥迪品牌以及奥迪下的奥迪A4和奥迪A6车系。车系被放在了dl中。

树形菜单采用模版比较合适,先把数据填充到模版,再把模版追加到页面元素。

当点击左侧树形导航上的品牌或车系,右侧通过iframe来呈现对应的内容。

领域先行。有关品牌和车系就抽象成如下的类:

    public class CarCategory
    {
        public int Id { get; set; }
        public int ParentId { get; set; }
        public string Name { get; set; }
        public string FirstLetter { get; set; }
        public string AnchorName { get; set; }
        public int Level { get; set; }
        public short DelFlag { get; set; }
    }

有关车型就抽象成如下的类:

    public class Car
    {
        public int Id { get; set; }
        public int PinPaiId { get; set; }
        public int CheXiId { get; set; } 
        public string Name { get; set; }
    }

页面左侧呈现树形导航需要向控制器请求json数据,大致格式是:

首字母
锚点名称
所有品牌
    品牌编号
    品牌名称
    所有车系
        车系编号
        车系名称
        车系下车型的总数量

貌似有3层,那就从最里面这层开始建模。有关车系在树形导航中的显示:

    public class CheXiForDisplay
    {
        public int CheXiId { get; set; }
        public int TotalCount { get; set; }
        public string CheXiName { get; set; }
    }

有关品牌在树形导航中的显示:

    public class PinPaiForDisplay
    {
        public int PinPaiId { get; set; }
        public string PinPaiName { get; set; }
        public List<CheXiForDisplay> CheXis { get; set; }
    }

有关品牌车系分组的:

    public class PinPaiCheXiForDisplay
    {
        public string FirstLetter { get; set; }
        public string Anchor { get; set; }
        public List<PinPaiForDisplay> PinPais { get; set; }
    }

数据源从哪里来?模拟了一个:

    public class Database
    {
        public static IEnumerable<CarCategory> GetAllCarCategories()
        {
            return new List<CarCategory>
            {
                new CarCategory(){Id = 1, ParentId = 0, Name = "奥迪",FirstLetter = "A", AnchorName = "AA", Level = 1, DelFlag = 0},
                new CarCategory(){Id = 2, ParentId = 0, Name = "宝马",FirstLetter = "B", AnchorName = "BB", Level = 1, DelFlag = 0},
                new CarCategory(){Id = 3, ParentId = 0, Name = "保时捷",FirstLetter = "B", AnchorName = "BB", Level = 1, DelFlag = 0},
                new CarCategory(){Id = 4, ParentId = 0, Name = "长安",FirstLetter = "C", AnchorName = "CC", Level = 1, DelFlag = 0},
                new CarCategory(){Id = 5, ParentId = 0, Name = "大众",FirstLetter = "D", AnchorName = "DD", Level = 1, DelFlag = 0},
                new CarCategory(){Id = 6, ParentId = 0, Name = "东风",FirstLetter = "D", AnchorName = "DD", Level = 1, DelFlag = 0},
                new CarCategory(){Id = 7, ParentId = 0, Name = "丰田",FirstLetter = "F", AnchorName = "FF", Level = 1, DelFlag = 0},
                new CarCategory(){Id = 8, ParentId = 0, Name = "福特",FirstLetter = "F", AnchorName = "FF", Level = 1, DelFlag = 0},
                new CarCategory(){Id = 9, ParentId = 1, Name = "奥迪A4",FirstLetter = "A", AnchorName = "AA", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 10, ParentId = 1, Name = "奥迪A6",FirstLetter = "A", AnchorName = "AA", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 11, ParentId = 2, Name = "宝马1",FirstLetter = "B", AnchorName = "BB", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 12, ParentId = 2, Name = "宝马2",FirstLetter = "B", AnchorName = "BB", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 13, ParentId = 3, Name = "保时捷1",FirstLetter = "B", AnchorName = "BB", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 14, ParentId = 3, Name = "保时捷2",FirstLetter = "B", AnchorName = "BB", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 15, ParentId = 4, Name = "长安1",FirstLetter = "C", AnchorName = "CC", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 16, ParentId = 4, Name = "长安2",FirstLetter = "C", AnchorName = "CC", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 17, ParentId = 5, Name = "大众1",FirstLetter = "D", AnchorName = "DD", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 18, ParentId = 5, Name = "大众2",FirstLetter = "D", AnchorName = "DD", Level = 2, DelFlag = 1},
                new CarCategory(){Id = 19, ParentId = 6, Name = "东风1",FirstLetter = "D", AnchorName = "DD", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 20, ParentId = 6, Name = "东风2",FirstLetter = "D", AnchorName = "DD", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 21, ParentId = 7, Name = "丰田1",FirstLetter = "F", AnchorName = "FF", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 22, ParentId = 7, Name = "丰田2",FirstLetter = "F", AnchorName = "FF", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 23, ParentId = 8, Name = "福特1",FirstLetter = "F", AnchorName = "AFF", Level = 2, DelFlag = 0},
                new CarCategory(){Id = 24, ParentId = 8, Name = "福特2",FirstLetter = "F", AnchorName = "AFF", Level = 2, DelFlag = 0}
            };
        }
        public static IEnumerable<Car> GetAllCars()
        {
            return new List<Car>
            {
                new Car(){Id = 1, PinPaiId = 1, CheXiId = 9, Name = "奥迪A401"},
                new Car(){Id = 2, PinPaiId = 1, CheXiId = 9, Name = "奥迪A402"},
                new Car(){Id = 3, PinPaiId = 1, CheXiId = 10, Name = "奥迪A601"},
                new Car(){Id = 4, PinPaiId = 1, CheXiId = 10, Name = "奥迪A602"},
                new Car(){Id = 5, PinPaiId = 2, CheXiId = 11, Name = "宝马101"},
                new Car(){Id = 6, PinPaiId = 2, CheXiId = 11, Name = "宝马102"},
                new Car(){Id = 7, PinPaiId = 2, CheXiId = 12, Name = "宝马201"},
                new Car(){Id = 8, PinPaiId = 2, CheXiId = 12, Name = "宝马202"},
                new Car(){Id = 9, PinPaiId = 3, CheXiId = 13, Name = "保时捷101"},
                new Car(){Id = 10, PinPaiId = 3, CheXiId = 13, Name = "保时捷102"},
                new Car(){Id = 11, PinPaiId = 3, CheXiId = 14, Name = "保时捷201"},
                new Car(){Id = 12, PinPaiId = 3, CheXiId = 14, Name = "保时捷202"},
                new Car(){Id = 13, PinPaiId = 4, CheXiId = 15, Name = "长安101"},
                new Car(){Id = 14, PinPaiId = 4, CheXiId = 15, Name = "长安102"},
                new Car(){Id = 15, PinPaiId = 4, CheXiId = 16, Name = "长安201"},
                new Car(){Id = 16, PinPaiId = 4, CheXiId = 16, Name = "长安202"},
                new Car(){Id = 17, PinPaiId = 5, CheXiId = 17, Name = "大众101"},
                new Car(){Id = 18, PinPaiId = 5, CheXiId = 17, Name = "大众102"},
                new Car(){Id = 19, PinPaiId = 5, CheXiId = 18, Name = "大众201"},
                new Car(){Id = 20, PinPaiId = 5, CheXiId = 18, Name = "大众202"},
                new Car(){Id = 21, PinPaiId = 6, CheXiId = 19, Name = "东风101"},
                new Car(){Id = 22, PinPaiId = 6, CheXiId = 19, Name = "东风102"},
                new Car(){Id = 23, PinPaiId = 6, CheXiId = 20, Name = "东风201"},
                new Car(){Id = 24, PinPaiId = 6, CheXiId = 20, Name = "东风202"},
                new Car(){Id = 25, PinPaiId = 7, CheXiId = 21, Name = "丰田101"},
                new Car(){Id = 26, PinPaiId = 7, CheXiId = 21, Name = "丰田102"},
                new Car(){Id = 27, PinPaiId = 7, CheXiId = 22, Name = "丰田201"},
                new Car(){Id = 28, PinPaiId = 7, CheXiId = 22, Name = "丰田202"},
                new Car(){Id = 29, PinPaiId = 8, CheXiId = 23, Name = "福特101"},
                new Car(){Id = 30, PinPaiId = 8, CheXiId = 23, Name = "福特102"},
                new Car(){Id = 31, PinPaiId = 8, CheXiId = 24, Name = "福特201"},
                new Car(){Id = 32, PinPaiId = 8, CheXiId = 24, Name = "福特202"}
            };
        }
    }       

好,现在可以向控制器要数据了。

   public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
        //获取所有首字母以及锚点的json
        public ActionResult GetFirstLettersJson()
        {
            var allCarCategories = Database.GetAllCarCategories();
            var result = from l in allCarCategories
                group l by l.FirstLetter
                into g
                select new {firstletter = g.Key, anchor=g.ToList()[0].AnchorName};
            return Json(result, JsonRequestBehavior.AllowGet);
        }
        //获取按首字母分组后的品牌车系json
        public ActionResult GetPinPaiCheXiJson() 
        {
            var allPinPais = Database.GetAllCarCategories().Where(c => c.Level == 1).OrderBy(c => c.FirstLetter);
            var allPinPaisGroup = from p in allPinPais
                group p by new
                {
                    p.FirstLetter,
                    p.AnchorName
                };
            List<PinPaiCheXiForDisplay> result1 = new List<PinPaiCheXiForDisplay>();
            foreach (var item in allPinPaisGroup)
            {
                //品牌车系
                PinPaiCheXiForDisplay pinPaiCheXiForDisplay = new PinPaiCheXiForDisplay();
                pinPaiCheXiForDisplay.FirstLetter = item.Key.FirstLetter;
                pinPaiCheXiForDisplay.Anchor = item.Key.AnchorName;
                
                //品牌
                List<PinPaiForDisplay> pinPaiForDisplays = new List<PinPaiForDisplay>();
                foreach (var pinpai in item.ToList())
                {
                    PinPaiForDisplay pinPaiForDisplay = new PinPaiForDisplay();
                    pinPaiForDisplay.PinPaiId = pinpai.Id;
                    pinPaiForDisplay.PinPaiName = pinpai.Name;
                    
                    //车系
                    List<CheXiForDisplay> cheXiForDisplays = new List<CheXiForDisplay>();
                    var cheXis = Database.GetAllCarCategories().Where(c => c.ParentId == pinpai.Id).OrderBy(c => c.Id);
                    foreach (var chexi in cheXis)
                    {
                        CheXiForDisplay cheXiForDisplay = new CheXiForDisplay();
                        cheXiForDisplay.CheXiId = chexi.Id;
                        cheXiForDisplay.CheXiName = chexi.Name;
                        cheXiForDisplay.TotalCount = cheXis.Count();
                        cheXiForDisplays.Add(cheXiForDisplay);
                    }
                    pinPaiForDisplay.CheXis = cheXiForDisplays;
                    pinPaiForDisplays.Add(pinPaiForDisplay);
                }
                pinPaiCheXiForDisplay.PinPais = pinPaiForDisplays;
                result1.Add(pinPaiCheXiForDisplay);
            }
            return Json(result1, JsonRequestBehavior.AllowGet);
        }
        //根据品牌Id显示车型
        public ActionResult GetCheXingsByPId(int pid)
        {
            var cars = Database.GetAllCars().Where(c => c.PinPaiId == pid);
            return View(cars);
        }
        //根据车系Id显示车型
        public ActionResult GetCheXingsByChexiId(int cxid)
        {
            var cars = Database.GetAllCars().Where(c => c.CheXiId == cxid);
            return View(cars);
        }
    }

在Shared/_Layout.cshtml中,该引用的css,js都要引用上。

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link href="~/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    @Styles.Render("~/Content/css")
    @RenderSection("styles", required: false)
    @Scripts.Render("~/bundles/jquery")
    <script src="~/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
    @RenderBody()
    
    @RenderSection("scripts", required: false)
</body>  

Home/Index.cshtml就负责显示就行了。

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section styles
{
    <link href="~/Content/sidemenu.css" rel="stylesheet" />
}
<div class="row">
    <div class="col-md-2 col-lg-2 col-sm-2">
        <!--字母导航开始-->
        <div id="lDaoHang">
        </div>
        <!--字母导航结束-->
        <!--树开始-->
        <div id="cTreeDiv" style="overflow-x: hidden; overflow-y: scroll; height: 550px; width: 99%;">
        </div>
        <!--树结束-->
        <div>
            <dl id="test"></dl>
        </div>
    </div>
    <div class="col-md-10 col-lg-10 col-sm-10">
        <div class="carContent" id="carContent">
            <iframe id="frameCar" src="" scrolling="no" frameborder="0" height="100%" width="100%" onload="this.height=this.contentWindow.document.documentElement.scrollHeight"></iframe>
        </div>
    </div>
</div>
@section scripts
{
    <script src="~/Scripts/jquery.tmpl.min.js"></script>
    <script type="text/javascript">
        $(function () {
            //加载首字母
            $.getJSON('@Url.Action("GetFirstLettersJson", "Home")', function (data) {
                $('#firstLetterTemplate').tmpl(data).appendTo('#lDaoHang');
            });
            //加载所有品牌车系
            $.getJSON('@Url.Action("GetPinPaiCheXiJson", "Home")', function (data) {
                $('#pinpaiTemplate').tmpl(data).appendTo('#cTreeDiv');
                $('.pLink').each(function () {
                    pinPaiInitialState($(this));
                });
            });
            //隐藏ifame所在div
            $("#carContent").css("display", "none");
            //点击品牌
            $('#cTreeDiv').on("click", ".pLink", function () {
                //切换
                togglePinPaiState($(this));
                //显示右边区域
                var url = "/Home/GetCheXingsByPId?pid=" + $(this).attr('id');
                $("#frameCar").attr("src", url);
                $("#carContent").css("display", "block");
            });
            //点击车系
            $('#cTreeDiv').on("click", ".cxLink", function () {
                //显示右边区域
                var url = "/Home/GetCheXingsByChexiId?cxid=" + $(this).attr('id');
                $("#frameCar").attr("src", url);
                $("#carContent").css("display", "block");
            });
        });
        //品牌的初始状态,即把车系隐藏和品牌前面的图标为+号
        var pstate = 0;
        //品牌只有2种状态:所有车系隐藏,品牌前面的图标变为为+号;要么显示品牌下的所有车系,品牌前面的图标变为-号
        //把车系隐藏和品牌前面的图标为+号,记为状态0
        //把车系隐藏和品牌前面的图标为-号,记为状态1
        function togglePinPaiState($pinpai) {
            if (pstate == 0) {
                var $i = $pinpai.parent().find("i");
                var attr = $i.attr('class');
                if (typeof attr !== typeof undefined && attr !== false) {
                    $i.removeClass("iconHide");
                }
                $i.addClass("iconShow");
                $pinpai.parent().parent().find("dl").show();
                pstate = 1;
            } else {
                var $j = $pinpai.parent().find("i");
                var attr1 = $j.attr('class');
                if (typeof attr1 !== typeof undefined && attr1 !== false) {
                    $j.removeClass("iconShow");
                }
                $j.addClass("iconHide");
                $pinpai.parent().parent().find("dl").hide();
                pstate = 0;
            }
        }
        function pinPaiInitialState($pinpai) {
            pstate = 0;
            togglePinPaiState($pinpai);
        }
    </script>
    <!--首字母模版-->
    <script id="firstLetterTemplate" type="text/x-jQuery-tmpl">
        <div class="lWrapper">
            <a href="#${anchor}" class="lLink">${firstletter}</a>
        </div>
    </script>
    <!--品牌模版-->
    <script id="pinpaiTemplate" type="text/x-jQuery-tmpl">
        <div class="lHeader" id="${Anchor}">${FirstLetter}</div>
        <ul class="uTree">
            {{if PinPais}}
            {{each PinPais}}
            <li>
                <h5 class="font-bold">
                    <a href="javascript:void(0)" class="pLink" id="${$value.PinPaiId}"><i></i>${$value.PinPaiName}</a>
                </h5>
                <dl>
                    {{tmpl(CheXis) "#chexiTemplate"}}
                </dl>
            </li>
            {{/each}}
            {{else}}
            <li>没有对应品牌</li>
            {{/if}}
                
        </ul>
    </script>
    <!--车系模版-->
    <script id="chexiTemplate" type="text/x-jQuery-tmpl">
        <dd><a id="${CheXiId}" href="javascript:void(0)" class="cxLink">${CheXiName}<em>(${TotalCount})</em></a></dd>
    </script>
}

以上,
○ 从控制器返回的有关树形菜单的json数据,先填充到jquery.tmpl.min.js模版中,然后追加到页面上。
○ 树形菜单的展开或收缩,通过全局变量pstate在0和1之间的切换来实现,页面初次加载给变量pstate一个初始值。


另外,点击树形导航上的品牌,iframe加载的视图是Home/GetCheXingsByPId.cshtml

@model IEnumerable<MvcApplication1.Models.Car>
@{
    ViewBag.Title = "GetCheXingsByPId";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>GetCheXingsByPId</h2>
<div>
    @foreach (var item in Model)
    {
        <p>@item.Name </p>
    
    }
</div>

点击树形导航上的车系,iframe加载的视图是Home/GetCheXingsByChexiId.cshtml

@model IEnumerable<MvcApplication1.Models.Car>
@{
    ViewBag.Title = "GetCheXingsByChexiId";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>GetCheXingsByChexiId</h2>
<div>
    @foreach (var item in Model)
    {
        <p>@item.Name </p>
    
    }
</div

就这样。

相关文章:

mongodb学习笔记6--杂项与补充

2019独角兽企业重金招聘Python工程师标准>>> 1。适用场景&#xff1a;持久化缓存层&#xff0c;高效的时效性&#xff0c;用于对象和Json数据的存储&#xff0c;高伸缩性的场景&#xff0c;大尺寸&#xff0c;低价值的数据存储。 不适用&#xff1a;高度事务性的场景…

GraphSAGE:我寻思GCN也没我厉害!

作者 | 郭必扬来源 | SimpleAI&#xff08;ID:SimpleAI_1&#xff09;众所周知&#xff0c;2017年ICLR出产的GCN现在是多么地热门&#xff0c;仿佛自己就是图神经网络的名片。然而&#xff0c;在GCN的风头中&#xff0c;很多人忽略了GCN本身的巨大局限——Transductive Learnin…

CxImage的编译及简单使用举例

1、 从http://sourceforge.net/projects/cximage/下载最新的CxImage 702源码&#xff1b; 2、 解压缩后&#xff0c;以管理员身份打开CxImageFull_vc10.sln工程&#xff0c;在编译之前先将每个工程属性的Character Set由原先的Use Unicode Character Set改为Use Multi-ByteC…

如何使用好android的可访问性服务(Accessibility Services)

原文&#xff1a;http://android.eoe.cn/topic/android_sdk * 主题* Manifest声明和权限 可访问性服务声明 可访问性服务配置 AccessibilityService方法 获得事件细节 示例代码 主要的类*AccessibilityService AccessibilityServiceInfo AccessibilityEvent AccessibilityReco…

自动驾驶人的福音!Lyft公开Level 5部署平台Flexo细节

作者 | Mathias Gug等&#xff0c;Lyft Level 5 软件工程师译者 | Lucy编辑 | 夕颜出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;导读&#xff1a;经过一年半的 bootstrapping&#xff08;一种再抽样统计方法&#xff09;&#xff0c;Lyft 让 Level 5 实现区分非常…

Cygwin的安装及在Android jni中的简单使用举例

Cygwin是一个在windows平台上运行的类UNIX模拟环境&#xff0c;是cygnussolutions公司开发的自由软件。Cygwin是许多自由软件的集合&#xff0c;Cygwin的主要目的是通过重新编译&#xff0c;将POSIX系统上的软件移植到Windows上。Cygwin包括了一套库&#xff0c;该库在win32系统…

university, school, college, department, institute的区别

这些个词没有太大区别&#xff0c;有时候有些词是可以通用的&#xff0c;而有些用法则是随着地域时间的不同而变迁。一般说来&#xff0c;college译作“学院”&#xff0c;它是university &#xff08;综合性大学&#xff09;的一个组成部分&#xff0c;例如&#xff0c;一所综…

XML简介及举例

可扩展标记语言(eXtensibleMarkup Language&#xff0c;简称XML)&#xff0c;是一种标记语言。标记指计算机所能理解的信息符号&#xff0c;通过此种标记&#xff0c;计算机之间可以处理包含各种信息的文章等。如何定义这些标记&#xff0c;既可以选择国际通用的标记语言&#…

关于事务的传播特性和隔离级别的问题

REQUIRED&#xff1a;业务方法需要在一个事务中运行。如果方法运行时&#xff0c;已经处在一个事务中&#xff0c;那么加入到该事务&#xff0c;否则为自己创建一个新的事务。 NOT_SUPPORTED&#xff1a;声明方法不需要事务。如果方法没有关联到一个事务&#xff0c;容器不会为…

[Big Data - Kafka] kafka学习笔记:知识点整理

一、为什么需要消息系统 1.解耦&#xff1a; 允许你独立的扩展或修改两边的处理过程&#xff0c;只要确保它们遵守同样的接口约束。 2.冗余&#xff1a;消息队列把数据进行持久化直到它们已经被完全处理&#xff0c;通过这一方式规避了数据丢失风险。许多消息队列所采用的&q…

自然语言处理十问!独家福利

最近&#xff0c;NLP 圈简直不要太热闹&#xff01;预训练模型频频刷新榜单&#xff0c;让一众研究者、开发者“痛并快乐着”。自 2018 年 10 月&#xff0c;Google 提出 BERT 以来&#xff0c;NLP 领域预训练模型的发展仿佛坐上了火箭&#xff0c;完全控制不住。BERT 出世前&a…

BERT的成功是否依赖于虚假相关的统计线索?

作者 | 李理来源 | 个人博客导读&#xff1a;本文介绍论文Probing Neural Network Comprehension of Natural Language Arguments&#xff0c;讨论BERT在ACRT任务下的成绩是否依赖虚假的统计线索&#xff0c;同时分享一些个人对目前机器学习尤其是自然语言理解的看法。目录论文…

【电子基础】模拟电路问答

模拟电路基础知识问答整理 mystery 1、温度对半导体材料的导电性能有什么影响? 答&#xff1a;温度对半导体的导电性能有很大影响。当温度升高时&#xff0c;半导体材料内的自由电子和空穴数量迅速增加&#xff0c;半导体的导电性能将迅速提高。 2、什么是本征半导体和杂质半导…

XML解析简介及Xerces-C++简单使用举例

XML是由World WideWeb联盟(W3C)定义的元语言。它已经成为一种通用的数据交换格式&#xff0c;它的平台无关性&#xff0c;语言无关性&#xff0c;系统无关性&#xff0c;给数据集成与交互带来了极大的方便。XML在不同的语言里解析方式都是一样的&#xff0c;只不过实现的语法不…

[干货]Kaggle热门 | 用一个框架解决所有机器学习难题

新智元推荐 来源&#xff1a;LinkedIn 作者&#xff1a;Abhishek Thakur 译者&#xff1a;弗格森 【新智元导读】本文是数据科学家Abhishek Thakur发表的Kaggle热门文章。作者总结了自己参加100多场机器学习竞赛的经验&#xff0c;主要从模型框架方面阐述了机器学习过程中可能会…

gtest简介及简单使用

gtest是一个跨平台(Liunx、Mac OS X、Windows、Cygwin、Windows CE and Symbian)的C测试框架&#xff0c;有google公司发布。gtest测试框架是在不同平台上为编写C测试而生成的。从http://code.google.com/p/googletest/downloads/detail?namegtest-1.7.0.zip&can2&q下…

新浪微博推广网站的一些实践体会

本以为微博推广很难&#xff0c;每天都要刷粉刷内容的&#xff0c;也本以为做微博推广也很简单&#xff0c;一不卖产品、二不卖服务的&#xff0c;目的单纯灵活性强些&#xff0c;做了之后才发现都不是那么回事&#xff0c;微博虽然也过了“火了”&#xff0c;但新媒体还真是不…

AI和大数据如何落地智能城市?京东城市这6篇论文必读 | KDD 2019

来源 | 京东城市&#xff08;ID: icity-jd&#xff09;作为世界数据挖掘领域的最高级别的学术会议&#xff0c;ACM SIGKDD&#xff08;国际数据挖掘与知识发现大会&#xff0c;简称 KDD&#xff09;将于 2019 年 8 月 4 日—8 日在美国阿拉斯加州安克雷奇市举行。自 1995 年以来…

OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so

OSError: Could not find library geos_c or load any of its variants [libgeos_c.so.1, libgeos_c.so 解决&#xff1a; sudo vim /etc/ld.so.conf 添加&#xff1a;/opt/source/geos-3.5.0/build/lib sudo ldconfig

五分钟搭建BERT服务,实现1000+QPS​,这个Service-Streamer做到了

作者 | 刘欣简介&#xff1a;刘欣&#xff0c;Meteorix&#xff0c;毕业于华中科技大学&#xff0c;前网易游戏技术总监&#xff0c;现任香侬科技算法架构负责人。之前专注游戏引擎工具架构和自动化领域&#xff0c;2018年在GDC和GoogleIO开源Airtest自动化框架&#xff0c;广泛…

Nagios+pnp4nagios+rrdtool 安装配置为nagios添加自定义插件(三)

nagios博大精深&#xff0c;可以以shell、perl等语句为nagios写插件&#xff0c;来满足自己监控的需要。本文写mysql中tps、qps的插件&#xff0c;并把收集到的结果以图形形式展现出来&#xff0c;这样输出的结果就有一定的要求了。 编写插件tps qps check_qps 插件如下内容 #…

OpenSSL简介及在Windows、Linux、Mac系统上的编译步骤

OpenSSL介绍&#xff1a;OpenSSL是一个强大的安全套接字层密码库&#xff0c;囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议&#xff0c;并提供丰富的应用程序供测试或其它目的使用。 SSL是SecureSockets Layer(安全套接层协议)的缩写&#xff0c;可以在Interne…

Guava Cache本地缓存在 Spring Boot应用中的实践

概述 在如今高并发的互联网应用中&#xff0c;缓存的地位举足轻重&#xff0c;对提升程序性能帮助不小。而 3.x开始的 Spring也引入了对 Cache的支持&#xff0c;那对于如今发展得如火如荼的 Spring Boot来说自然也是支持缓存特性的。当然 Spring Boot默认使用的是 SimpleCache…

Windows 8.1 Preview(Windows Blue)预览版简体中文官方下载(ISO完整版镜像)

Windows 8.1是微软继Windows 8以来的又一全新力作&#xff0c;又名Windows Blue&#xff08;视窗蓝&#xff0c;专注蓝屏30年&#xff09;&#xff0c;个人觉得Win8还是比较流畅的但大众始终觉得还是有很多需要改进或者改善的&#xff0c;如今微软为了迎合大众需求对Win8进行升…

Linux下编辑器vi/vim的使用介绍

vi编辑器是所有Unix及Linux系统下标准的编辑器。对Unix及Linux系统的任何版本&#xff0c;vi编辑器是完全相同的。 基本上vi可以分为三种状态&#xff0c;分别是命令模式(commandmode)、插入模式(insert mode)和底行模式(last line mode)&#xff0c;各模式的功能为&#xff1…

Clojure程序设计

《Clojure程序设计》基本信息作者&#xff1a; (美)Stuart Halloway Aaron Bedra [作译者介绍]出版社&#xff1a;人民邮电出版社ISBN&#xff1a;9787115308474上架时间&#xff1a;2013-3-1出版日期&#xff1a;2013 年3月开本&#xff1a;16开页码&#xff1a;230版次&#…

重磅!AI Top 30+案例评选正式启动

2019 年&#xff0c;人工智能应用落地的重要性正在逐步得到验证&#xff0c;这是关乎企业生死攸关的一环。科技巨头、AI 独角兽还有起于草莽的创业公司在各领域进行着一场多方角斗。进行平台布局的科技巨头们&#xff0c;正在加快承载企业部署 AI 应用的步伐&#xff0c;曾经无…

直播回顾 | 关于Apollo 5.0控制在环仿真技术的分享

Apollo 用于模型验证和测试的基于 Web 的仿真平台 Dreamland 已经更新到能使用更强大的场景编辑器和环控制模拟。基于 Apollo 流水线和机器学习的动力学模型&#xff0c;复杂度较高&#xff0c;同时基于 AI 的全景数据建模&#xff0c;模型精细度高&#xff0c;误差比传统方式可…

eclipes 安装 pytdev,svn,插件

1&#xff0c; python pydevhttp://pydev.org/updates2, svnhttp://subclipse.tigris.org/update3, 推荐http://subclipse.tigris.org/update_1.10.x 转载于:https://blog.51cto.com/swq499809608/1240873

FFmpeg简介及在vc2010下编译步骤

FFmpeg是一个开源的多媒体库&#xff0c;最新版本是2.4.3&#xff0c;它的License是LGPL或GPL。FFmpeg可以用来记录、转换数字音频、视频&#xff0c;并能将其转换为流的开源计算机程序。它包括了音/视频编码库libavcodec。FFmpeg是在Linux下开发出来的&#xff0c;但它可以在包…