element tp6实现轮播图

引入在线的   

  <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
 <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
 <!-- 引入axios -->
<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>

                                                                                                                                         HTML

<div id="app">
        <!--    轮播    -->
        <el-aside width=70%>
            <el-card class="box-card">
                <div slot="header" class="clearfix">
                    <span>轮播图</span>
                </div>
                .
                <div class="text item">
                    <div class="block">
                        <el-carousel height="600px">
                            <el-carousel-item v-for="(item,value) in banner">
                                <img :src="item.image" style="width: 100%" height="100%">
                            </el-carousel-item>
                        </el-carousel>
                    </div>
                </div>
            </el-card>
        </el-aside>
</div>

                                                                                                                                                  JS

 var vm = new Vue({
        el: "#app",
        data: {
            banner: []
        },
        created: function () {
            var that = this
            axios.get("banner")
                .then(res => {
                    // console.log(res.data.data)
                    that.banner = res.data.data
                }).catch(function (error) {
                console.log(error)
            });
        },
        methods: {}
    })

                                                                                                                                                  CSS

 <style>
        .el-aside {
            background-color: #D3DCE6;
            color: #333;
            text-align: center;
        }

        .el-main {
            background-color: #D3DCE6;
            color: #333;
            text-align: center;
        }
 </style>

                                                                                                                                         controller

public function banner(){
         $res=Banner::image();
         if ($res!==false){
             return json(["code"=>1,"data"=>$res,"msg"=>"轮播图"]);
         }
    }

                                                                                                                                             model

  static public function image()
    {
        $res = Banner::select();
        $res && $res = $res->toArray();
        return $res;
    }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值