vue商品组件封装

效果:

在这里插入图片描述

API :

img :照片路径,
title :标题名字,
describe :描述,
obj :对象{ price: 现价,originalPrice:原价,sales:销量 }

代码:

<template>
    <div @click="clicks()">
        <div class="llen">
            <div class="img">
                <img :src="img">
            </div>
            <div class="xq">
                <p>{{title}}</p>
                <p style="margin: .3rem 0; ">{{describe}}</p>
                <p style="font-size: 14px; display: flex;justify-content: space-between">
                    <b style="color: red">现价:{{obj.price}}</b><s>原价:{{obj.originalPrice}}</s><span>销量{{obj.sales }}</span>
                </p>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "L-len",
        props: {
            img: {
                default: 'https://dcdn.it120.cc/2019/07/24/a30b67dd-61be-41bd-841c-7e3f8844e958.jpg',
                type: String
            },
            title: {
                default: 'Title标题',
                type: String
            },
            describe: {
                default: '描述',
                type: String
            },
            obj: Object,
        },
        components: {},
        data() {
            return {}
        },
        mounted() {
        },
        methods: {
            clicks(t) {
                this.$emit('click', t)
            }
        },
    }
</script>

<style scoped>
    .xq {
        width: 60%;
    }

    .llen {
        padding: .1rem 0;
        width: 100%;
        display: flex;
        justify-content: space-around;
        align-items: center;
        border-top: .02rem solid #eee;
        border-bottom: .01rem solid #eee;
    }

    .llen .img {
        width: 25%;
        border-radius: .1rem;
        overflow: hidden;
    }

    .llen .img img {
        width: 100%;
    }

</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值