| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <script src="./js/vue.js"></script>
- <script src="./js/ajax.js"></script>
- <style>
- .product-card {
- width: 234px;
- /* 如果数值为0 那么单位可以省略 如果值是0.X 0也可以省略 0.5=.5 */
- box-shadow: 0 0 10px rgba(0, 0, 0, .5);
- padding: 10px;
- text-align: center;
- float: left;
- margin-right: 20px;
- }
- .product-img img {
- width: 100%;
- }
- .product-title {
- /* 文字大小尽量不要小于12px */
- font-size: 14px;
- font-weight: 400;
- color: #333;
- }
- .product-info {
- font-size: 12px;
- color: #b0b0b0;
- text-wrap: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin-top: 10px;
- margin-bottom: 20px;
- }
- .product-price span {
- color: #ff6700;
- }
- .product-price del {
- color: #b0b0b0;
- }
- </style>
- </head>
- <body>
- <div id="app">
- <div class="btn">
- <button v-on:click="getProduct">获取商品</button>
- </div>
- <div class="product-list">
- <div class="product-card" v-for="item in productList">
- <div class="product-img">
- <img :src="item.pic" alt="img">
- </div>
- <div class="product-title">{{item.prodName}}</div>
- <div class="product-info">{{item.brief}}</div>
- <div class="product-price">
- <span>{{item.price}}</span>
- </div>
- </div>
- </div>
- </div>
- <script>
- new Vue({
- el: "#app",
- data: {
- productList: []
- },
- methods: {
- getProduct() {
- let _this = this;
- ajax("GET","http://shop-api.edu.koobietech.com/prod/tagProdList",function(res){
- console.log(res.data[0].productDtoList);
- _this.productList = res.data[0].productDtoList;
- })
- }
- }
- })
- </script>
- </body>
- </html>
|