Skip to content

Commit eb0a31a

Browse files
committed
function support
1 parent ea7d0f1 commit eb0a31a

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

index.html

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,14 @@
2929
<summary>
3030
设定
3131
</summary>
32-
<input id="chn" type="checkbox" onclick="chnClick(this)" checked="true">启用中文</input>
33-
<input id="3d" type="checkbox" v-model="td">启用三维</input>
32+
<input type="checkbox" onclick="chnClick(this)" checked="true">启用中文</input>
33+
<input type="checkbox" v-model="td" onlick="tdClick">启用三维</input>
3434
</details>
3535
<details>
3636
<summary>
3737
数据
3838
</summary>
39-
<div class="type">
40-
<button v-on="{mouseenter: onFunctionEnter, mouseleave: onFunctionLeave}">函数</button>
41-
<button v-on="{mouseenter: onPlotEnter, mouseleave: onPlotLeave}">散点</button>
42-
</div>
43-
<div>
44-
<input type="text" v-model="series">
45-
<span v-show="series">{{series}}</span>
46-
</div>
39+
<expression></expression>
4740
</details>
4841
<details>
4942
<summary>

web/js/main.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Vue.component('expression',{
2+
template:'<tr><td>函数</td><td><input type="text" v-model="param" @keyup="on_change"></td><td><input type="text" v-model="expression" @keyup="on_change"></td></tr>',
3+
data: function(){
4+
return {
5+
param: "",
6+
expression: "",
7+
}
8+
},
9+
methods:{
10+
on_change: function(){
11+
if(!app.td)
12+
app.series = "\\addplot [" + this.param + "] {" + this.expression + "};";
13+
else
14+
app.series = "\\addplot3 [" + this.param + "] (" + this.expression + ");";
15+
},
16+
}
17+
});
18+
119
// 参数字典
220
var paramDic = new Array();
321

@@ -42,6 +60,10 @@ chnClick = function(obj){
4260
}
4361
};
4462

63+
tdClick = function(){
64+
65+
}
66+
4567
var app = new Vue({
4668
el: '#app',
4769
data:{
@@ -61,18 +83,6 @@ var app = new Vue({
6183
},
6284
},
6385
methods:{
64-
onFunctionEnter: function(){
65-
app.series = "Funtion";
66-
},
67-
onFunctionLeave: function() {
68-
app.series = "";
69-
},
70-
onPlotEnter: function() {
71-
app.series = "Plot";
72-
},
73-
onPlotLeave: function() {
74-
app.series = "";
75-
},
7686
compile: function() {
7787
// 清除换行无效符号
7888
app.curl = "https://latexonline.cc/compile?text="+this.file.replace(/[\r\n]/g,"");

0 commit comments

Comments
 (0)