我无法弄清楚如何检索当前的attr。输入类型范围元素的值。 attr。价值似乎不是'内部的attr。值'在幻灯片中更改。
的Javascript
'use-strict';
(function(){
var fooProt = Object.create(HTMLElement.prototype);
Object.defineProperty(fooProt, "bar", {
value: {test: 1},
writable: false,
enumerable: true
});
fooProt.getMin = function() {
return this.bar.test;
};
fooProt.attachedCallback = function () {
this.addEventListener('change', function(){
//get current value, following does not appear to work
//console.log(this.value);
});
};
var foo = document.registerElement('ex-foo', {prototype : fooProt, extends : 'input'});
})();
HTML
<input type="range" min="1" max="100" value="1" is="ex-foo" id="foo">
答案 0 :(得分:1)
HTMLElement
未向您提供value
属性,但HTMLInputElement
确实:
var fooProt = Object.create(HTMLInputElement.prototype);