-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.dev.html
executable file
·130 lines (114 loc) · 3.69 KB
/
index.dev.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
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head lang="en">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta charset="UTF-8">
<title>json2canvas 调试</title>
<link href="https://cdn.staticfile.org/jsoneditor/5.32.5/jsoneditor.min.css" rel="stylesheet">
<style>
html,
body {
height: 100%;
margin: 0;
padding: 0;
background: #FFFFFF
}
.app {
height: 100%;
display: flex;
flex-direction: row
}
.view {
padding: 20px;
}
.view-left {
border-right: #CCC solid 1px;
width: 30%
}
.view-right {
width: 70%
}
.jsonview {
width: 100%;
height: 900px;
overflow: scroll;
}
canvas {
border: #CCC 1px solid
}
</style>
</head>
<body>
<div class="app" id="app">
<div class="view view-left">
<div id="jsonview" class="jsonview">
</div>
<block v-for="item in radios">
<input type="radio" :id="item" :value="item" v-model="picked">
<label :for="item">{{item}}</label>
<br>
</block>
</div>
<div class="view">
<canvas id='myCanvas'></canvas>
</div>
</div>
<script src="https://cdn.staticfile.org/vue/2.6.10/vue.min.js"></script>
<script src="https://cdn.staticfile.org/jsoneditor/5.32.5/jsoneditor.min.js"></script>
<% if ( 'production' == htmlWebpackPlugin.options.mode ) { %>
<script src="https://unpkg.com/cax@1.3.1/dist/cax.js"></script>
<script src="./json2canvas.js"></script>
<% } else { %>
<% for ( var i = 0; i < htmlWebpackPlugin.files.js.length ;i++ ){ %>
<script type="text/javascript" src="<%= htmlWebpackPlugin.files.js[i] %>"></script>
<% } %>
<% } %>
<script src="./option.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
picked: '元素测试',
data: null,
editor: null,
radios: [],
},
watch: {
picked: function(newValue, oldValue) {
this.setCanvas(newValue);
}
},
mounted: function() {
let radios = [];
for (const key in option) {
radios.push(key);
}
this.radios = radios;
let url = new URL(window.location.href)
let param = new URLSearchParams(url.search);
param.get('picked') && (this.picked = param.get('picked'))
this.setCanvas(this.picked);
},
methods: {
setCanvas(picked) {
if (!this.editor) {
this.editor = new JSONEditor(document.getElementById("jsonview"), {
onChangeJSON: (json) => {
console.time('draw');
json2canvas.draw(json, '#myCanvas');
console.timeEnd('draw');
}
}, option[picked]);
this.editor.expandAll();
} else {
this.editor.update(option[picked])
}
console.time('draw');
json2canvas.draw(option[picked], '#myCanvas');
console.timeEnd('draw');
}
}
})
</script>
</body>
</html>