注意:我已经阅读了有关Symbols,WeekMaps和Maps 的以下SO问题和7个答案(截至目前),请在投票前阅读完整的问题:JavaScript ES6类中的私有属性
文章:https://esdiscuss.org/ 话题/ ES7-财产初始化
以下是我的Simple Class包含私有,公共和受保护的属性和方法.
'use strict';
class MyClass {
constructor () {
this.publicVar = 'This is Public Variable';
this.privateVar = 'This is Private Variable';
this.protectedVar = 'This is Protected Variable';
} // Public Constructor Method.
publicMethod () {
console.log(' Accessing this.publicVar: ', this.publicVar);
console.log(' Accessing this.privateVar: ', this.privateVar);
console.log(' Accessing this.protectedVar: ', this.protectedVar);
return 'Its Public Method'
} // Public Method.
privateMethod () {return 'Its Private Method'} // …Run Code Online (Sandbox Code Playgroud)看看下面的 CSS 样式,我计划将 LESS 和 SASS 用于两个不同的项目,这在preprocessors.
.longDots {
content: " ......................................................................................................";
}
.shortDots {
content: "....................";
}
Run Code Online (Sandbox Code Playgroud)
究竟是什么,我想避免重复点将其作为单点,并且太可配置而无法将其更改为
-, #, *
mixin像下面这样的东西。
.longDots {
content: repeater('.', 25);
}
.shortDots {
content: repeater('.', 10);
}
.longDashes {
content: repeater('-', 25);
}
.shortDashes {
content: repeater('-', 10);
}
Run Code Online (Sandbox Code Playgroud)