帮我写一个vue elementui商品详情页面好看的
时间: 2023-06-15 19:07:05 浏览: 168
好的,以下是一个简单的Vue ElementUI商品详情页面的示例代码:
```
<template>
<div class="product-details">
<el-row>
<el-col :span="12">
<img :src="product.image" alt="" class="product-image">
</el-col>
<el-col :span="12">
<h2>{{ product.name }}</h2>
<p class="product-description">{{ product.description }}</p>
<p class="product-price">{{ product.price }}</p>
<el-button type="primary" class="add-to-cart" @click="addToCart">Add to Cart</el-button>
</el-col>
</el-row>
</div>
</template>
<script>
export default {
data() {
return {
product: {
name: 'Sample Product',
description: 'This is a sample product description',
price: '$19.99',
image: 'https://via.placeholder.com/400x400'
}
}
},
methods: {
addToCart() {
// Add product to cart
}
}
}
</script>
<style scoped>
.product-image {
width: 100%;
max-width: 400px;
margin-bottom: 20px;
}
.product-description {
margin-bottom: 20px;
}
.product-price {
font-size: 24px;
margin-bottom: 20px;
}
.add-to-cart {
margin-top: 20px;
}
</style>
```
你可以根据需要进行自定义样式和修改数据来源,让页面更加符合你的需求。
阅读全文