elment排行

页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<style>
    .el-carousel__item img {
        color: #475669;
        font-size: 14px;
        opacity: 0.75;
        line-height: 150px;
        margin: 0;
    }

    .el-carousel__item:nth-child(2n) {
        background-color: #99a9bf;
    }

    .el-carousel__item:nth-child(2n+1) {
        background-color: #d3dce6;
    }
</style>
<body>
<div id="app">
    <el-container>
        <el-aside width="800px"><el-carousel height="300px" >
            <el-carousel-item v-for="item in carousel" :key="item">
                <img :src="item.img" style="width: 100%;height: 100%">
            </el-carousel-item>
        </el-carousel></el-aside>


        <el-main><el-tabs @tab-click="handleClick">
            <el-tab-pane label="用户管理" name="first">
                <table border="1px" width="600px">
                    <tr width="100px">
                        <td>ID</td>
                        <td>工作</td>
                        <td>内容</td>
                        <td>数量</td>
                    </tr>
                    <tr v-for="item in info" :key="item" width="100px">
                        <td>{{item.id}}</td>
                        <td>{{item.job}}</td>
                        <td>{{item.date}}</td>
                        <td>{{item.num}}</td>
                    </tr>
                </table>
            </el-tab-pane>
            <el-tab-pane label="配置管理" name="second">
                <table border="1px" width="600px">
                    <tr width="100px">
                        <td>ID</td>
                        <td>数量</td>
                    </tr>
                    <tr v-for="item in jiang" :key="item" width="100px">
                        <td>{{item.tid}}</td>
                        <td>{{item.name}}</td>
                    </tr>
                </table>
            </el-tab-pane>
        </el-tabs></el-main>
    </el-container>



</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            carousel:[],
            info:[],
            jiang:[]
        },
        methods: {
            handleClick(tab, event) {
                console.log(tab.name);
                if (tab.name === 'first'){
                    axios
                        .get('http://www.week3.com/Oly/bang/info').then(res => (
                        console.log(res.data.data),
                            this.info = res.data.data)).catch(function (error) { // 请求失败处理
                        console.log(error);
                    });
                }else if(tab.name === 'second'){
                    axios
                        .get('http://www.week3.com/Oly/bang/jiang').then(response => (
                        // console.log(response.data.data),
                            this.jiang = response.data.data)).catch(function (error) { // 请求失败处理
                        console.log(error);
                    });
                }

            }
        },
        created(){
            axios
                .get('http://www.week3.com/Oly/bang/create').then(response => (
                // console.log(response.data.data),
                    this.carousel = response.data.data)).catch(function (error) { // 请求失败处理
                console.log(error);
            });
        },
    })
</script>
</body>
</html>

控制器后台

public function create()
    {
        $data = img::select();
        $data && $data = $data->toArray();
        return json(['data'=>$data,'msg'=>'','code'=>0]);
    }

    /**
     * 保存新建的资源
     *
     * @return \think\Response
     */
    public function info()
    {
        $data = info::select();
        $data && $data = $data->toArray();
        return json(['data'=>$data,'msg'=>'','code'=>0]);
    }

    /**
     * 显示指定的资源
     *
     */
    public function jiang()
    {
        $data = type::select();
        $data && $data = $data->toArray();
        return json(['data'=>$data,'msg'=>'','code'=>0]);
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值