[英]Sending keys / manipulating value of input field (vue.JS input)
I'm trying to send data to an input field on this website: https://www.avigilon.com/how-to-buy/partner-locator我正在尝试将数据发送到此网站上的输入字段: https ://www.avigilon.com/how-to-buy/partner-locator
You can programmatically identify the input using the following:您可以使用以下方式以编程方式识别输入:
let input = $('input[placeholder="Zip code / Postal code"]')[0]
if you then pass input.value = '33701'
it will change the input, but the moment you press 'Search' it resets it to the null value.如果您随后传递
input.value = '33701'
,它将更改输入,但在您按下“搜索”的那一刻,它会将其重置为空值。
I typed a few keys in, then changed it using input.value = '33701'
and it reset it back to the keys i'd typed in manually, so I tried passing a keyup event like this: input.dispatchEvent(new KeyboardEvent('keyup', {'key': '3'}));
我输入了几个键,然后使用
input.value = '33701'
对其进行了更改,然后将其重置为我手动输入的键,因此我尝试像这样传递 keyup 事件: input.dispatchEvent(new KeyboardEvent('keyup', {'key': '3'}));
but it didnt add the key.但它没有添加密钥。 I added an event listener and the event is triggering, but the key is just not being added to the input.
我添加了一个事件侦听器并且事件正在触发,但是键没有被添加到输入中。
I tried this same event dispatch method in my own app and it accepted the key.我在自己的应用程序中尝试了相同的事件调度方法,它接受了密钥。 I also tried
keydown
and keypress
.我也试过
keydown
和keypress
。
I looked at the page source and noticed the input field has a property called v-model='selectedZipcode'
.我查看了页面源代码,发现输入字段有一个名为
v-model='selectedZipcode'
的属性。 I've never used Vue before so I didn't recognize it.我以前从未使用过Vue,所以我不认识它。 In doing research, it looks like the v-model input components accept keys differently to regular inputs.
在进行研究时,看起来 v-model 输入组件接受的键与常规输入不同。
I am struggling to find info on how I can pass keys into this v-model input.我正在努力寻找有关如何将密钥传递到此 v-model 输入的信息。
您甚至不需要设置邮政编码,只需引用 Vue 应用程序本身并调用:
app.getLocationFromZip(33701)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.