创业经验

img_v2_c80231ec-4a99-41a6-9da0-a0d49e1d071g
img_v2_c80231ec-4a99-41a6-9da0-a0d49e1d071g

带标签的模板

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Template_literals#%E5%B8%A6%E6%A0%87%E7%AD%BE%E7%9A%84%E6%A8%A1%E6%9D%BF

适合处理固定变量要加判断的格式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const person = "Mike";
const age = 28;

function myTag(strings, personExp, ageExp) {
const str0 = strings[0]; // "That "
const str1 = strings[1]; // " is a "
const str2 = strings[2]; // "."

const ageStr = ageExp > 99 ? "centenarian" : "youngster";

// 我们甚至可以返回使用模板字面量构建的字符串
return `${str0}${personExp}${str1}${ageStr}${str2}`;
}

const output = myTag`That ${person} is a ${age}.`;

console.log(output);
// That Mike is a youngster.

说说软件工作量评估这件事

  • 专家法
  • 类推/类比法
  • 方程法
Image
Image