vue 用v-model绑定的input,直接在js里.value赋值无效
解决办法:需要在.value赋值后,手动触发input事件let name = document.querySelector("#app > section > section > main > div.main.clearfix > div > div > div > p:nth-child(3) > input[type=text]")le
解决办法:
需要在.value赋值后,手动触发input事件
dom元素.value = "admin"
dom元素.dispatchEvent(new Event('input'))
例:fast os docker的登录页
let name = document.querySelector("#app > section > section > main > div.main.clearfix > div > div > div > p:nth-child(3) > input[type=text]")
let pass = document.querySelector("#app > section > section > main > div.main.clearfix > div > div > div > p:nth-child(5) > input[type=password]")
let login = document.querySelector("#app > section > section > main > div.main.clearfix > div > div > div > p.submit > button")
if(name && pass){
name.value = "admin"
name.dispatchEvent(new Event('input'))
pass.value = "888888"
pass.dispatchEvent(new Event('input'))
login.click()
}
更多推荐
所有评论(0)