我打算在 Polymer 中创建一个 classMixin,它提供自定义方法并将被其他元素继承。
一切都按预期工作,但我也想继承一些属性。
static get properties() {
return {
// Make this protected
test: {
value: 'test',
}
};
}
我如何使这个 test
属性受到保护,以便继承类可以使用它?
最佳答案
声明时加下划线即可
static get properties() {
return {
// Make this protected
_test: {
value: 'test',
}
};
}
关于javascript - 聚合物 2.0 类遗传保护特性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45413137/