码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-09-04 01:55:43      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:unit   java   class   console   shel   key   variable   word   step   

 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);

 

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

标签:unit   java   class   console   shel   key   variable   word   step   

原文地址:https://www.cnblogs.com/cisum/p/9581939.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!