Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想设置不同的ID。
第一个将是:id1
第二个:id2。
直到最后:id6。
我怎样才能做到这一点?
@for (int i = 0; i < 7; i++) { <img id="id + @i" src="img.jpg"> }
试试看:
@for (int i = 0; i < 7; i++) { <img id='@("id" + i)' src="img.jpg"> }
试试这个:只需对 i = 1 到 6 使用循环:
@for (int i = 1; i <= 6; i++) { <img id="id + @i" src="img.jpg"> }