-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue_carosul_multi_images.html
123 lines (118 loc) · 4.49 KB
/
vue_carosul_multi_images.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- third-party css -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/all.min.css">
<!--OSM Open Street Map 定位圖資--><link rel="stylesheet" href="js/third_party/leaflet1.9.3/leaflet.css" >
<!-- this css -->
<link rel="stylesheet" href="css/common_x.css">
<link rel="stylesheet" href="css/common_t.css">
<link rel="stylesheet" href="css/common_travel_map.css">
<title>一個Carosul多個image</title>
</head>
<body>
<div class="container" id="vue_app">
<div class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item" v-for="(carousel, index) in carousels" :key="index">
<div class="row">
<div class="col-md-6" v-for="(image, i) in carousel.images" :key="i">
<img :src="image.src" class="d-block w-100" alt="...">
</div>
<div class="col-md-6">
<div class="carousel-text" v-for="(text, i) in carousel.texts" :key="i">
<h3>{{ text.title }}</h3>
<p>{{ text.description }}</p>
</div>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="js/jquery-3.6.1.min.js"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
var cart = [
{
picture1: "https://fakeimg.pl/150x100/ffaa00/000000?text=FruitImage01&font=lobster&font_size=20",
name:"紅色火龍果",
qty:1,
},
{
picture1: "https://fakeimg.pl/150x100/aaaaff/000000?text=FruitImage01&font=lobster&font_size=20",
name:"白色火龍果",
qty:10,
},
{
picture1: "https://fakeimg.pl/150x100/00aa00/000000?text=FruitImage01&font=lobster&font_size=20",
name:"黃色火龍果",
qty:11,
},
{
picture1: "https://fakeimg.pl/150x100/ff00cc/000000?text=FruitImage01&font=lobster&font_size=20",
name: "紅肉李",
qty:3,
},
{
picture1: "https://fakeimg.pl/150x100/aa00ff/000000?text=FruitImage01&font=lobster&font_size=20",
name: "AAAAA",
qty: 5,
},
{
picture1: "https://fakeimg.pl/150x100/00ccff/000000?text=FruitImage01&font=lobster&font_size=20",
name: "BBBBBB",
qty:4,
},
{
picture1: "https://fakeimg.pl/150x100/00ff00/000000?text=FruitImage01&font=lobster&font_size=20",
name: "CCCC",
qty: 9,
},
{
picture1: "https://fakeimg.pl/150x100/ff55ff/000000?text=FruitImage01&font=lobster&font_size=20",
name: "DDDD",
qty: 8,
},
];
var App = {
data(){
return {
text1:"今天天氣很好",
data:[],
carousels:[],
}
},
created() {
var vm = this;
vm.data = cart;
let i, j, chunkSize = 5;
for (i = 0, j = vm.data.length; i < j; i += chunkSize) {
let chunk = vm.data.slice(i, i + chunkSize);
let texts = chunk.map(image => ({
title: image.picture1,
description: image.name
}));
carousels.push({ images: chunk, texts: texts });
}
},
methods: {
},
};
Vue.createApp(App).mount("#vue_app");
</script>
</body>
</html>