에 대한 문자열에 캐리지 리턴을 추가, 나는 긴 문자열을 가지고 유지 보수성 및 가독성을 위해 나는과 같이 코드에 줄 바꿈을 넣어하는 방법 그렇다면 :자바 스크립트 내가 궁금 가독성
slices +=
'<div
class="'+settings.sliceClass+'"
style="
width:' + slicewidth + 'px;
height:' + sliceheight + 'px;
left:' + left + 'px;
top:' + top + 'px;
"><img src="'+slide.properties.src+'"
style="
position: relative;
left:' + -left + 'px;
top:' + -top + 'px;
width:' + Math.round(slide.properties.image.width * slide.properties.scale.width) + 'px;
height:' + Math.round(slide.properties.image.height * slide.properties.scale.height) + 'px;
">
</img></div>'
);
HTML 출력에 이러한 줄 바꿈이 나타나기를 기대하지 않습니다.
그러나 이것은 SyntaxError: Unexpected EOF
을 반환합니다.
어쨌든 이것을 할 수 있습니까?
감사합니다. 누군가의 말을 대신 사용하는 것이 좋습니다. –
@ GeorgeReith, 대단합니다. ES의 다음 버전 인 Fyi는 [문자열 템플릿]의 부작용으로 여러 줄 문자열을 포함하게됩니다 (http://www.nczonline.net/blog/2012/08/01/a-critical- review-of-ecmascript-6-quasi-literals /) –