我有以下网络组件:
(function() {
var helloProto = Object.create(HTMLElement.prototype);
helloProto.createdCallback = function() {
var val = this.getAttribute('data-text') || 'stranger';
val = val.toUpperCase();
this.innerHTML = 'Hello, ' + val + '.';
};
document.registerElement('hello-el', {
prototype: helloProto
});
})();
这是从React组件的render函数中调用的:
<hello-el data-text="roger"></hello-el>
问题是this.getAttribute(&#39; data-text&#39;)返回undefined?为什么?