问题描述
解决我们的代码中的一些问题,我想知道元素中属性的顺序在涉及Angular时是否重要?
我在这里看到过一些帖子,对于纯HTML来说没什么关系,但是Angular相关标签和变量引用有区别吗?
例如,#inputRefEndDate应该在所有其他内容之前,还是matInput,还是需要在#inputRefDate或 根本不重要 之前?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table id="fooRegionTable">
<tr id="fooinformation" class="mtrow">
<th class="fooName" scope="row">name1</th>
<td class="fooCode" class="left-align-text">code1</td>
<td class="left-align-text">${foo.country}</td>
<td class="left-align-text">${foo.region}</td>
<td class="left-align-text">${foo.subregion}</td>
</tr>
<tr id="fooinformation" class="mtrow">
<th class="fooName" scope="row">name2</th>
<td class="fooCode" class="left-align-text">code2</td>
<td class="left-align-text">${foo.country}</td>
<td class="left-align-text">${foo.region}</td>
<td class="left-align-text">${foo.subregion}</td>
</tr>
</table>
<button id="search">click</button><input id="fooRegionSearch" />
解决方法
实际上,您正在使用这些扩展类定义。在类中声明变量不受顺序的影响,但是有保持可读性的最佳实践。
简短的回答是“否”。这不会影响代码的运行方式。
长答案是肯定的。这会影响长期的可读性,因此您应该遵循一定的模式并坚持下去!