how2j.cn

步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 展示数据   
步骤 4 : view.html   
步骤 5 : 测试   

步骤 1 :

先运行,看到效果,再学习

edit
老规矩,先下载右上角的可运行项目,配置运行起来,确认可用之后,再学习做了哪些步骤以达到这样的效果。

先启动 EurekaServerApplication
然后启动 IndexCodesApplication
接着启动 TrendTradingBackTestViewApplication
下一步启动 TrendTradingBackTestServiceApplication
最后启动 IndexZuulServiceApplication
注: 记得运行redis-server.exe 以启动 redis 服务器
然后访问地址:

http://127.0.0.1:8031/api-view/

于是就可以看到在视图上获取到了从网关取到的数据了。
先运行,看到效果,再学习
在确保可运行项目能够正确无误地运行之后,再严格照着教程的步骤,对代码模仿一遍。
模仿过程难免代码有出入,导致无法得到期望的运行结果,此时此刻通过比较正确答案 ( 可运行项目 ) 和自己的代码,来定位问题所在。
采用这种方式,学习有效果,排错有效率,可以较为明显地提升学习速度,跨过学习路上的各个槛。

推荐使用diffmerge软件,进行文件夹比较。把你自己做的项目文件夹,和我的可运行项目文件夹进行比较。
这个软件很牛逼的,可以知道文件夹里哪两个文件不对,并且很明显地标记出来
这里提供了绿色安装和使用教程:diffmerge 下载和使用教程
接下来就要在空白的 模拟回测视图 上增加内容了。
view.html 做了如下改动
1. data4Vue 增加了 indexes 和默认选中的指数 currentIndex

var data4Vue = {
indexes: [],
currentIndex: '000300',
};

2. 修改 init 函数, 访问网关的 api-codes 获取所有指数代码

init:function(){
var url = "http://127.0.0.1:8031/api-codes/codes";
axios.get(url).then(function(response) {
vue.indexes = response.data;
});
}

3. 遍历这个指数代码集合

<table class="inputTable ">
<tr>
<td width="25%">
<span data-toggle="tooltip" data-placement="top" title="选择某一个指数进行模拟回测">
请选择指数:<span class="glyphicon glyphicon-question-sign" > </span>
</span>
</td>
<td width="25%">
<select v-model="currentIndex" class="indexSelect form-control">
<option v-for="bean in indexes " :value="bean.code">{{bean.name}} - ( {{bean.code}} )</option>
</select>
</td>
<td></td>
<td></td>
</tr>
</table>

4. 高亮 tooltips, 这个是bootstrap 里的 提示工具

$("[data-toggle='tooltip']").tooltip();
<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head th:include="include/header::html('趋势投资模拟回测')" ></head> <body > <script> $(function(){ var data4Vue = { indexes: [], currentIndex: '000300', }; //ViewModel var vue = new Vue({ el: '#workingArea', data: data4Vue, mounted:function(){ //mounted 表示这个 Vue 对象加载成功了 this.init(); $("[data-toggle='tooltip']").tooltip(); }, methods: { init:function(){ var url = "http://127.0.0.1:8031/api-codes/codes"; axios.get(url).then(function(response) { vue.indexes = response.data; }); } } }); }); </script> <style> table.inputTable{ width:100%; } table.inputTable td{ padding:20px 20px; } table{ margin:20px; } div#workingArea{ margin:50px; } </style> <div id="workingArea"> <span class="label label-info">回测参数</span> <table class="inputTable "> <tr> <td width="25%"> <span data-toggle="tooltip" data-placement="top" title="选择某一个指数进行模拟回测"> 请选择指数:<span class="glyphicon glyphicon-question-sign" > </span> </span> </td> <td width="25%"> <select v-model="currentIndex" class="indexSelect form-control"> <option v-for="bean in indexes " :value="bean.code">{{bean.name}} - ( {{bean.code}} )</option> </select> </td> <td></td> <td></td> </tr> </table> </div> <div th:replace="include/footer::html" ></div> </body> </html>
先启动 EurekaServerApplication
然后启动 IndexCodesApplication
接着启动 TrendTradingBackTestViewApplication
最后启动 IndexZuulServiceApplication
然后访问地址:

http://127.0.0.1:8031/api-view/

于是就可以看到在视图上获取到了从网关取到的数据了。


HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。


提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 回收站-------不要的------模拟回测-指数代码 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 578362961
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: https://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图