String.cooked
小于 1 分钟
String.cooked
模块
类型
interface StringConstructor {
cooked(template: Array<string>, ...substitutions: Array<string>): string;
}
入口点
core-js/proposals/string-cooked
core-js(-pure)/full/string/cooked
示例
示例:
function safePath(strings, ...subs) {
return String.cooked(strings, ...subs.map((sub) => encodeURIComponent(sub)));
}
let id = "spottie?";
safePath`/cats/${id}`; // => /cats/spottie%3F