We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当前的代码中为了避免 template strings 产生多余的缩进,导致代码格式很奇怪,可以使用 tagged templates 来优化代码格式。 例如:
function unIndent(strings, ...values) { const text = strings .map((s, i) => (i === 0 ? s : values[i - 1] s)) .join(""); const lines = text.replace(/^\n/u, "").replace(/\n\s*$/u, "").split("\n"); const lineIndents = lines.filter(line => line.trim()).map(line => line.match(/ */u)[0].length); const minLineIndent = Math.min(...lineIndents); return lines.map(line => line.slice(minLineIndent)).join("\n"); } function getCodeSnippet() { return unIndex` var world = 'world'; console.log('hello, ' world); `; } // 而不必为了避免多余的缩进,将 template strings 置与行首 function getCodeSnippet() { return ` var world = 'world'; console.log('hello, ' world); `; }
如上
The text was updated successfully, but these errors were encountered:
您的 Issue 没有按照规范从 Taro Issue Helper 创建,因此会被直接关闭。
维护开源项目是一项非常辛苦的工作,还请多多包涵。 了解为什么这么严格?
Sorry, something went wrong.
No branches or pull requests
这个特性解决了什么问题?
当前的代码中为了避免 template strings 产生多余的缩进,导致代码格式很奇怪,可以使用 tagged templates 来优化代码格式。
例如:
这个 API 长什么样?
如上
The text was updated successfully, but these errors were encountered: