vue.jsreactivesearch

Looking for an example implementation of @valueChange in a ReactiveSearch Vue component


I am struggling to get any implementation of the @valueChange event working in a Vue component.

I have added it to one of the 'official' tutorials here, but I only get errors.

All I want is to log/alert a message when the selected value from search changes.

Here you can see me trying to add the event, on line 24: https://codesandbox.io/s/4z4vy9zpw

Thanks!


Solution

  • Try this

    @valueChange="
      (function(value) {
        this.console.log('current value:', value)
      })($event)
    "
    

    Or

    // template
    
    @valueChange="handleValue"
    
    // script
    
    methods: {
      ...
      handleValue (value) {
        console.log('current value:', value)
      }
    }