0

How to update the Vue form field through the DOM?

I need to update field data through an external script. For this I need to know if it is possible to update the data through the DOM.

https://codesandbox.io/s/compassionate-feistel-26r4v?file=/src/store.js

I tried to do it directly through the Store, but in my case it doesn't work.

How to call the VueJs object via Chrome Extension?

Example

window.document.getElementsByClassName('el-input__inner')[0].value = 10
marcelo.delta
  • 2,730
  • 5
  • 36
  • 71

1 Answers1

1

you can use ref for similar to querySelector reference in SFC.

in <template>:

<input type="text" ref="thisRef" name="textfield_1"/>

in <script> methods call:

this.$refs.thisRef[0].value = 10

Other than that, there's v-model for data binding.

hope helps

SC Kim
  • 545
  • 4
  • 14