多行字符串

该警告类别由 qmllint 拼写[multiline-strings]

字符串包含未换行的行结束符,已被弃用

发生了什么事?

字符串跨越多行。

为什么会这样?

跨多行的字符串是 ECMAScript 的非标准扩展,在 QML 中已被弃用。请使用模板文字代替。

示例

import QtQuick

Item {
    property string multiLine: "first
second
third"

    property string multiLine2: 'first
second
third'
}

要修复此警告,请使用模板字面形式,或者用"\n "替换换行符:

import QtQuick

Item {
    property string multiLine: `first
second
third`
    property string multiLine2: `first
second
third`

    property string alternative: "first\nsecond\nthird"
    property string alternative2: "first\n" +
"second\n" +
"third"
}

© 2025 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.