<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<ul>
<li v-for="(tab, index) in tabs" :key="index" @click="change(index)">{{tab}}</li>
</ul>
<child :m="m"></child>
</div>
</body>
<script src="vue.min.js"></script>
<script>
Vue.component('child', {
props: {
m: {
type: Array
}
},
template: `
<div class="child">
<img v-for="(a, i) in m" :key="i" :src="a.vertical_image_url" />
</div>
`
})
new Vue({
el: "#app",
data: {
tabs: ['编辑推荐', "最新上架"],
m: [1, 2, 3]
},
methods: {
change(i) {
if (i == 0) {
this.m = [1, 2, 3]
fetch("https://www.kuaikanmanhua.com/v2/pweb/ugc/topics").then(res => res.json()).then(res1 => {
this.m = [...res1.data.list]
})
} else {
fetch("https://www.kuaikanmanhua.com/v2/pweb/ugc/rec_topics").then(res => res.json()).then(res1 => {
this.m = [...res1.data.topics]
})
}
}
}
})
</script>
</html>