-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
83 lines (82 loc) · 2.81 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
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>live2d demo</title>
</head>
<body>
<div id="app">
<div>
<div>
<div>请选择一个模型:</div>
<!-- radio选择模型 嵌套div实现简单按钮效果 -->
<div v-for="(model,index) in models" :key="index" @click="status.json = model.value"
style="display: inline-block;cursor: pointer;border: 1px solid;border-radius: .5rem;margin: 1rem .5rem 0;min-width: 120px;text-align: center;padding: 5px;"
:style="{borderColor: (status.json == model.value ? '#0075ff':'rgba(0,0,0,.33)')}">
<label style="cursor: unset;margin-left: 8px">{{model.name}}</label>
<input type="radio" name="models" :value="model.value" v-model="status.json"
style="margin: 3px 8px 0 0;cursor: unset">
</div>
</div>
</div>
<!-- pointer-events: none; 实现点击穿透 -->
<canvas class="live2d" id="live2d" width="300" height="300" style="pointer-events: none;"></canvas>
</div>
<script src="js/vue-2.7.14.js"></script>
<script src="js/live2d.min.js"></script>
<script>
const vm = new Vue({
el: '#app',
watch: {
'status.json': {
handler(val, prev) {
// 核心代码,通过这个方法重新加载json
loadlive2d("live2d", this.status.json);
},
deep: true
}
},
data: {
status: {
json: '',
checkIndex: 0
},
models: [
{
'name': '22娘(B站)',
'value': 'model/22/model.default.json'
},
{
'name': '33娘(B站)',
'value': 'model/33/model.default.json'
},
{
'name': '羊栖菜(黑猫)',
'value': 'model/hijiki/hijiki.model.json'
},
{
'name': '山药泥(白猫)',
'value': 'model/tororo/tororo.model.json'
},
{
'name': '小埋',
'value': 'model/xiaomai/xiaomai.model.json'
},
{
'name': '碗中小年糕',
'value': 'model/wanko/wanko.model.json'
},
{
'name': '血小板',
'value': 'model/platelet-3/kesyoban.model.json'
}
]
},
methods: {},
mounted() {
// 给个默认值 变化后会触发watch
this.status.json = this.models[0].value;
}
});
</script>
</body></html>