在 ES6 中, 我们可以使用重音号声明模板字符串, 好处是可以引用 js 环境中的变量, 语法是使用 ${variable}
这种形式, 例如 ${username}
有时我们想增加条件 if 判断, 可以在 ${variable}
中使用三目运算符
// ${delTablePrefix == 0 ? "checked" : "" }
let text = `
<input type="checkbox" ${delTablePrefix == 0 ? "checked" : "" }>删除表前缀
`;