Home  >  Article  >  Web Front-end  >  What are the advantages and disadvantages of layui framework

What are the advantages and disadvantages of layui framework

清浅
清浅Original
2019-02-19 15:45:0614460browse

The advantage of the layui framework is that it is a lightweight framework, which is simple and suitable for back-end development; the disadvantage is that the technology is not very mature yet, and it is more troublesome to interact with the front-end because it needs to query the DOM operation

layui is A modular front-end framework that is popular for its simple yet substantial nature. Today I will introduce the advantages and disadvantages of the layui framework, which has certain reference value and I hope it will be helpful to everyone.

【Recommended course: javascript tutorial

layui meaning:

layui is a front-end UI framework written using its own module specifications. It follows the native HTML/CSS/JS writing method. Although it is minimalist in appearance, it is rich in content and contains many components from core code to API, which are very suitable for rapid development of interfaces. In fact, layui is more for back-end developers, and it has its own mode. More lightweight and simple

What are the advantages and disadvantages of layui framework

The advantages and disadvantages of layui

The advantages are as follows:

( 1) layui is a lightweight framework, simple and beautiful. Suitable for developing back-end mode, it has very good results on server-side pages.

(2) layui is the best UI framework provided to back-end developers. It is based on DOM driver. As long as it does not involve interaction, layui is still very good.

The disadvantages are as follows:

(1) layui appeared late, and it must be that other front-end frameworks are still immature. Now it has been updated to version 2.

##Case: Implement carousel effect through layui framework

What are the advantages and disadvantages of layui framework(1) Externally import layui files

<link rel="stylesheet" type="text/css" href=".\layui-v2.4.5\layui\css\layui.css">
<script src=.\layui-v2.4.5\layui\layui.js></script>

(2) Carousel image code:

<div class="layui-carousel" id="test1" lay-filter="carofilter" style="font-size:larger">
        <div carousel-item>
            <div style="background-color:pink;">图1</div>
            <div style="background-color:lightblue">图2</div>
            <div style="background-color:blue">图3</div>
            <div style="background-color:mediumorchid">图4</div>
            <div style="background-color:orange">图5</div>
        </div>
    </div>
    <script src=.\layui-v2.4.5\layui\layui.js></script>
    <script>
        layui.use(&#39;carousel&#39;, function () {
            var carousel = layui.carousel;
            var ins=carousel.render({
                elem: &#39;#test1&#39;
                , width: &#39;450px&#39;     //设置容器宽度
                , arrow: &#39;always&#39;    //始终显示箭头,可选hover,none
                //,anim: &#39;updown&#39;    //切换动画方式,可选fade,default
                , full: false        //全屏
                , autoplay: true     //自动切换
                , interval: 1000     //自动切换的时间间隔
                , index: 3           //初始化时item索引,默认时0
                , indicator:&#39;inside&#39; //指示器位置,可选outside,none
            });
            //监听轮播切换事件
            carousel.on(&#39;change(carofilter)&#39;, function (obj) { //test1来源于对应HTML容器的 
            lay-filter="test1" 属性值
                console.log(obj.index);     //当前条目的索引
                console.log(obj.prevIndex); //上一个条目的索引
                console.log(obj.item);      //当前条目的元素对象
            });

            //重置轮播
            ins.reload({arrow:&#39;hover&#39;});//将arror从alway变成hover
        });
    </script>

Effect picture:

Summary: The above is this This is the entire content of this article. I hope this article can help everyone learn the layui framework better

The above is the detailed content of What are the advantages and disadvantages of layui framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn