【发布时间】:2019-08-07 09:31:37
【问题描述】:
我对反应很陌生,我只想在我的表单中使用这个https://github.com/jackocnr/intl-tel-input 插件。但是在文档中说要使用纯js输入id查询选择器来使用插件。但是如何更改这种代码以响应使用情况。
文档中的代码示例:
<input type="tel" id="phone">
<script src="path/to/intlTelInput.js"></script>
<script>
var input = document.querySelector("#phone");
window.intlTelInput(input);
</script>
【问题讨论】:
-
在反应中查看refs
-
@BoyWithSilverWings 但如何通过 refs 使用 window.intlTelInput(input)
-
ref 将为您提供调用 intlTelInput 的 DOM 节点。你会想要在 componentDidMount 和/或 componentDidUpdate 中调用。
标签: reactjs