-
Notifications
You must be signed in to change notification settings - Fork 0
/
新闻卡片 copy 2.html
84 lines (74 loc) · 2.21 KB
/
新闻卡片 copy 2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Card Example</title>
<style>
.card {
display: flex;
flex-direction: column;
align-items: center;
width: 480px;
height: 480px;
border: 1px solid #ccc;
border-radius: 15px;
padding: 20px;
background-image:linear-gradient(0deg,#a8edea 0%, #fed6e3 100%)
}
.title {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.content {
font-size: 16px;
margin-bottom: 20px;
}
.image {
width: 100%;
height: 200px;
object-fit: cover;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="card">
<img class="image" src="" alt="">
<h2 class="title">标题</h2>
<p class="content"></p>
<p class="source"></p>
<p class="time"></p>
</div>
<script>
// 获取需要更新的卡片元素
const cardElement = document.getElementsByClassName('.card');
// 获取需要更新的卡片数据
fetch('https://api.vika.cn/fusion/v1/datasheets/dst9mc5CYEGRRbfWxy/records?viewId=viwNzBnq8ZZwn&fieldKey=name', {
headers: {
'Authorization': 'Bearer uskdyEpUL0mOcLBBDrU5mbE'
}
})
.then(response => response.json())
.then(json => {
var objj = (json);
})
// .then(data => {
// console.log(data);
// // 更新卡片的标题、内容和配图
// // document.getElementsByClassName('.title').innerHTML = message;
// const titleElement = document.querySelector('.title');
// titleElement.textContent = data.records[0].fields.content;
// const contentElement = cardElement.querySelector('.content');
// contentElement.textContent = data.records[0].fields.content;
// const imageElement = cardElement.querySelector('.image');
// imageElement.src = data.records[0].fields.image;
// })
.catch(error => console.error(error));
var obj = JSON.parse(objj);
console.log(obj);
let biaoti = document.querySelector(".title");
console.log(biaoti);
</script>
</body>
</html>