前后端分离?

开始


某次面试叫现场写页面,居然吧=把单词写错了,还一直没看出来错误,真是蠢,没事还是多写写吧

页面

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <title>移动端布局</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        #wrap {
            height: 100%;
            width: 100%;
        }

        .header {
            width: 100%;
            height: 50px;
        }

        .header>ul {
            width: 100%;
            height: 100%;
        }

        .header ul>li {
            width: 25%;
            height: 100%;
            box-sizing: border-box;
            padding: 15px;
            float: left;
            list-style: none;
            text-align: center;
            transition: all .5s;
        }

        .header ul>li:hover {
            box-shadow: 0 5px 3px gray;
        }

        .content {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: flex-start;
            align-content: flex-start;
            border: 1px solid red;
        }

        .content>.goods {
            width: 50%;
        }

        .left {
            width: 60%;
            height: 130px;
            float: left;
            box-sizing: border-box;
            padding: 15px;
        }

        .left>img {
            width: 100%;
            height: 100%;
        }

        .right {
            width: 40%;
            float: left;
            height: 100%;
            box-sizing: border-box;
            padding: 5px;
        }

        .right h4 {
            white-space: wrap;
            font-size: 12px;
        }

        .right p:nth-of-type(1) {
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            width: 100%;
            font-size: 12px;
            transform: scale(0.7, 0.7);
        }

        .range {
            width: 100%;
            font-size: 12px;
            overflow: hidden;
        }

        .range span {
            display: block;
            width: 30%;
            float: left;
            text-align: center;
            border-radius: 10%;
            margin-left: 2px;
        }

        .range span:nth-child(1) {
            background-color: hotpink;
        }

        .range span:nth-child(2) {
            background-color: gold;
        }

        .range span:nth-child(3) {
            background-color: purple;
        }

        .price {
            color: orange;
            font-size: 12px;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div id="wrap">
        <div class="header">
            <ul>
                <li>价格</li>
                <li>分类</li>
                <li>筛选</li>
                <li>抢购</li>
            </ul>
        </div>
        <div class="content">
            <div class="goods" v-for="(item,index) in data" :key="index">
                <div class="left">
                    <img :src="item.imgUrl" alt="">
                </div>
                <div class="right">
                    <h4>{{item.name}}</h4>
                    <p>{{item.dec}}</p>
                    <div class="range">
                        <span>{{item.d1}}</span>
                        <span>{{item.d2}}</span>
                        <span>{{item.d3}}</span>
                    </div>
                    <p class="price">{{item.price}}<del>{{item.del_price}}</del></p>
                </div>
            </div>
        </div>
    </div>
    <script>
        new Vue({
            el: '#wrap',
            data() {
                return {
                    data: []
                }
            },
            mounted() {
                this.getData()
            },
            methods: {
                getData() {
                    axios.get('http://localhost:5000/data')
                        .then((response) => {
                            this.data = response.data.arr
                            //console.log(response.data)
                        })
                }
            }
        })
    </script>
</body>

</html>

接口

const Koa = require('koa')
const router = require('koa-router')()
const jsonp = require('koa-jsonp')
const cors = require('koa2-cors')

const app = new Koa()

app.use(jsonp())
app.use(cors())

router.get('/',async (ctx) => {
    ctx.body = 'Hello Koa!'
})
router.get('/data',async (ctx) => {
    ctx.body = {
        arr:[
            {
                imgUrl:'04.png',
                name:'孟德尔豌豆 优良品种 直购',
                dec:'孟德尔耗时数十年培育出来的优良品种,你还在犹豫什么呢',
                d1:'实惠',
                d2:'满减',
                d3:'双11',
                price:'¥429',
                del_price:'¥599'
            },
            {
                imgUrl:'10.png',
                name:'SWEECOE羊羔',
                dec:'2019新款冬装加绒外套',
                d1:'天猫',
                d2:'冲',
                d3:'双11',
                price:'¥199',
                del_price:'¥999'
            },
            {
                imgUrl:'12.png',
                name:'NIKE 正品 鞋',
                dec:'NIKE/耐克正品2020新款AIR MAX WILDCARD HC',
                d1:'实惠',
                d2:'劵后',
                d3:'双11',
                price:'¥424',
                del_price:'¥599'
            },
            {
                imgUrl:'20.png',
                name:'百事可乐 330ml*24罐',
                dec:'330ml*24罐整箱 七喜美年达经典口味碳酸饮料',
                d1:'实惠',
                d2:'满减',
                d3:'双11',
                price:'¥99',
                del_price:'¥199'
            }
        ]
    }
})

app.use(router.routes())
app.use(router.allowedMethods())
//监听端口
app.listen(5000)
console.log('http://localhost:5000/')

样子
在这里插入图片描述
不知道为什么那几个span里面的字排不到一行,没弄出来,还请看出来问题出在哪儿的,不吝赐教一下!谢谢

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值