V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
V2EX  ›  Jonatvtwoex  ›  全部回复第 1 页 / 共 1 页
回复总数  1
原因是校验逻辑依赖 input 事件, 而 inputEle.value = xxx 并不会触发 input 事件

const inputEle = document.querySelector(`input[name=${key}]`)
inputEle.value = fields[key]
// 关键代码: input 元素在事后触发一下 input 事件
inputEle.dispatchEvent(new Event('input'));
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4133 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 10ms · UTC 05:18 · PVG 13:18 · LAX 22:18 · JFK 01:18
♥ Do have faith in what you're doing.