fengchuanyu 3 months ago
parent
commit
198d35ff75
3 changed files with 130 additions and 44 deletions
  1. 47 0
      .gitignore
  2. 0 44
      6_ES6/练习商品卡片.html
  3. 83 0
      6_ES6/练习题10_商品卡片.html

+ 47 - 0
.gitignore

@@ -0,0 +1,47 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+**/node_modules
+# roadhog-api-doc ignore
+/src/utils/request-temp.js
+_roadhog-api-doc
+ant-pro
+
+# production
+/dist
+/.vscode
+
+# misc
+.DS_Store
+npm-debug.log*
+yarn-error.log
+
+/coverage
+.idea
+yarn.lock
+package-lock.json
+*bak
+.vscode
+
+# visual studio code
+.history
+*.log
+
+functions/mock
+.temp/**
+
+# umi
+.umi
+.umi-production
+
+# screenshot
+screenshot
+.firebase
+
+# mine
+testWebpack
+test
+笔记
+面试
+练习题
+测试代码

+ 0 - 44
6_ES6/练习商品卡片.html

@@ -1,44 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Document</title>
-    <style>
-        body{
-            background-color: #f5f5f5;
-        }
-        .card-content{
-            width: 250px;
-            /* border:1px solid black; */
-            margin: 0 auto;
-            padding: 20px;
-            background-color: #fff;
-            /* 阴影  第一个值横向偏移 第二个值纵向偏移 第三个值扩散值 第四个值阴影颜色 */
-            box-shadow: 0 0 5px #666;
-        }
-        .card-img{
-            text-align: center;
-        }
-        .card-img img{
-            width: 200px;
-        }
-        /* .card-info h3{
-            margin-left: 20px;
-        } */
-        
-    </style>
-</head>
-<body>
-    <div class="card-content">
-        <div class="card-img">
-            <img src="./img/img2.png" alt="图片">
-        </div>
-        <div class="card-info">
-            <h3>精美智能手机</h3>
-            <p>高清屏幕,强大性能,出色拍照。</p>
-            <p>¥3999</p>
-        </div>
-    </div>
-</body>
-</html>

+ 83 - 0
6_ES6/练习题10_商品卡片.html

@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <style>
+        body {
+            background-color: #f5f5f5;
+        }
+
+        .card-content {
+            width: 250px;
+            /* border:1px solid black; */
+            float: left;
+            padding: 20px;
+            background-color: #fff;
+            /* 阴影  第一个值横向偏移 第二个值纵向偏移 第三个值扩散值 第四个值阴影颜色 */
+            box-shadow: 0 0 5px #666;
+            margin:10px;
+        }
+
+        .card-img {
+            text-align: center;
+        }
+
+        .card-img img {
+            width: 200px;
+        }
+
+        .card-info h3,.card-info p{
+            text-wrap: nowrap;
+            overflow: hidden;
+            text-overflow: ellipsis;
+        }
+        .clearfix::after{
+            content: "";
+            display: block;
+            clear: both;
+        }
+        .title-bar{
+            float: left;
+            width: 100%;
+        }
+    </style>
+</head>
+
+<body>
+    <div class="box clearfix">
+        
+    </div>
+
+    <script src="./ajax.js"></script>
+    <script>
+        let oBox = document.getElementsByClassName("box")[0];
+        ajaxFun("GET", "http://shop-api.edu.koobietech.com/prod/tagProdList", function (res) {
+            let dataList = res.data;
+            let htmlStr = "";
+            for(let j=0;j<dataList.length;j++){
+                htmlStr += `<div class="title-bar">${dataList[j].title}</div>`
+                for(let i=0;i<dataList[j].productDtoList.length;i++){
+                    let {pic,prodName,brief,price} = dataList[j].productDtoList[i];
+                    htmlStr += `
+                        <div class="card-content">
+                            <div class="card-img">
+                                <img src="${pic}" alt="图片">
+                            </div>
+                            <div class="card-info">
+                                <h3>${prodName}</h3>
+                                <p>${brief}</p>
+                                <p>¥${price}</p>
+                            </div>
+                        </div>
+                    `
+                }
+            }
+            oBox.innerHTML = htmlStr;
+        })
+    </script>
+</body>
+
+</html>