선언 전에 var 사용
qmllint에서는 이 경고 범주를 ' [var-used-before-declaration] '로 표기합니다.
변수가 선언되기 전에 사용되었습니다
무슨 일이 발생했나요?
변수를 선언하기 전에 사용했습니다.
왜 문제가 될까요?
이로 인해 코드의 가독성이 떨어집니다. let 또는 const 로 선언된 변수는 런타임에 오류가 발생합니다.
예시
import QtQuick
Item {
function f() {
x = 42; // x is used before its declaration
let x;
}
Component.onCompleted: f()
}이 경고를 해결하려면 선언을 사용 위치보다 앞쪽으로 이동하세요:
import QtQuick
Item {
function f() {
let x;
x = 42;
}
Component.onCompleted: f()
}QML 문서의 JavaScript 표현식항목도 참조하십시오 .
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.