forked from blanzh/carsBase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
53 lines (46 loc) · 1.32 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
</head>
<body>
<div id="app">
<select v-model="level1" @change="chooselevel1">
<option :value="item" v-for="item in Object.keys(level1List)">{{item}}</option>
</select>
<select v-model="level2" v-if="level1">
<option :value="item" v-for="item in level2List">{{item}}</option>
</select>
<hr>
<b><a target="_blank" :href="`https://www.google.com/search?q=${level1}%20${level2}&tbm=isch`">{{level1 }} {{ level2 }}</a></b>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
level1: "",
level2: "",
level1List: [],
level2List: [],
json: []
},
methods: {
chooselevel1() {
this.level2 = ""
this.level2List = []
this.level2List = this.level1List[this.level1]
},
},
async mounted() {
const response = await axios.get('cars.json')
this.json = response.data
this.level1List = this.json.list
console.log(this.level1List);
}
})
</script>
</body>
</html>