Skip to content

Commit d9208fb

Browse files
committed
Multiple properties
1 parent 0f4c9b2 commit d9208fb

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<link rel="stylesheet" href="web/css/main.css">
99
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
1010
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
11+
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
1112
</head>
1213
<body>
1314
<div class="nav">
@@ -43,8 +44,11 @@
4344
参数
4445
</summary>
4546
<div>
46-
<table>
47+
<table id="propcon">
4748
<property chname="标题" propkey="title"></property>
49+
<tr>x轴</tr>
50+
<property chname="最小" propkey="xmin"></property>
51+
<property chname="最大" propkey="xmax"></property>
4852
</table>
4953
</div>
5054
</details>

web/js/main.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1+
var paramDic = new Array();
2+
13
Vue.component('property',{
24
template:'<tr><td>{{chname}}</td><td>{{propkey}}</td><td><input :type="type" v-model="value" @keyup="on_change"></td></tr>',
35
props: ['chname','propkey'],
46
data: function(){
57
return {
68
type: "text", //属性的数据类型
7-
value: "", //属性的值
8-
}
9-
},
10-
computed:{
11-
paramString: function(){
12-
return this.propkey + "={" + this.value + "},";
9+
value: "", //属性的值
1310
}
1411
},
1512
methods:{
1613
on_change: function(){
17-
if(this.value!="")
18-
app.param = this.paramString;
19-
else
20-
app.param = "";
14+
paramDic[this.propkey] = this.value;
15+
16+
app.param = "";
17+
for(var key in paramDic)
18+
if(paramDic[key]!="")
19+
app.param += key + "={" + paramDic[key] + "},";
20+
2121
}
2222
}
2323
});
2424

25+
2526
var app = new Vue({
2627
el: '#app',
2728
data:{
@@ -30,15 +31,13 @@ var app = new Vue({
3031
premable:"\\documentclass[tikz]{standalone}\n\
3132
\\usepackage{pgfplots}\n\
3233
\\pgfplotsset{compat=1.14}\n\
33-
\\begin{document}\n\
34-
\\begin{tikzpicture}",
35-
suffix:"\\end{tikzpicture}\n\
36-
\\end{document}",
34+
\\begin{document}\n",
35+
suffix:"\\end{document}",
3736
curl:"",
3837
},
3938
computed:{
4039
content: function(){
41-
return "\\begin{axis}["+this.param+"]\n "+this.series+"\n\\end{axis}";
40+
return "\\begin{tikzpicture}\n\\begin{axis}["+this.param+"]\n "+this.series+"\n\\end{axis}\n\\end{tikzpicture}";
4241
},
4342
file: function(){
4443
return this.premable+this.content+this.suffix;

0 commit comments

Comments
 (0)