hjzheng / CUF_meeting_knowledge_share

Record CUF team meeting knowledge share
121 stars 49 forks source link

2014-12-16 ES6 Template String | 写给大家看的设计书 #21

Open hjzheng opened 9 years ago

hjzheng commented 9 years ago

ES6 Template String

//Basic usage with an expression placeholder
var person = 'Hao Ju Zheng';
console.log(`Yo! My name is ${person}`);

//Expressions work just as well with object literals
var user = {name: 'Zhen Ou Yun'};
console.log(`Thanks, ${user.name}`);

//Expression interpolation, One use is readable inline math.
var a = 50;
var b = 100;
console.log(`The number of JS frameworks is ${a + b} and not ${ 2 * a +b }`);

//Multi-line strings without needing \n\
console.log(`string text line 1
string text line 2`);

//Function inside expressions
function fn() {return "result"}
console.log(`foo ${fn()} bar`);

浏览器支持情况

hjzheng commented 9 years ago

推荐一本书《写给大家看的设计书》

在这部畅销全球多年、影响了一代设计师的经典著作中,作者将优秀设计的秘诀归纳为对比、重复、 对齐和亲密性四条基本原则,用简洁通俗、幽默生动的文笔,配以大量经过修改进行前后对比的实例 图解和设计练习(并提供解答),直观而清晰地传授给读者。

设计四个基本原则: