【发布时间】:2019-02-05 10:12:51
【问题描述】:
我正在尝试将输入字段包装在自定义元素中。
自定义元素 DOM 如下所示:
<custom-element>
<div class="fancy-wrapper">
<input value="4">
</div>
<custom-element>
虽然元素应该像这样工作:
<custom-input id="test"></custom-input>
<script>
let test = document.getElementById('test')
console.log(test.value); // should return 4 (value of inner input)
test.onkeydown = function(e){
console.log(e.target.value); // should the new value of the inner input
};
</script>
有什么方法可以将<custom-input> 属性重定向到其中的<input> 属性,而无需手动连接所有内容?
【问题讨论】:
标签: javascript html custom-element