javascript - 你不容错过的es6模板写法

 1  /**
 2      * ``即重音符(128键盘左上角ESC下面那个键盘)
 3      *   隶属:模板字符串
 4      */
 5 
 6     let unit = '4';
 7     let keywords = 'uc';
 8 
 9     // step1:模板变量 ${variable_name}
10     let url = `Shell${keywords}${unit}`;
11     console.log(url);
12 
13     //
14     let urls = 'Shell' + keywords + unit;
15     console.log(urls);
16 
17 
18 
19     // step2: 模板制作(更加智能化)
20     let view = `
21     <view class="${url}">${unit}</view>
22     <view class="${url}${unit}">${unit}</view>
23     `;
24     console.log(view);
25 
26     //
27     let views = "<view class=" + url + unit + ">" + url + "</view>";
28     console.log(views);

 

posted @ 2018-09-03 23:48  Sunsin  阅读(371)  评论(0编辑  收藏  举报