Vue $ listeners understand how the property?

First, what $ listeners that?

Suppose parent component and subassembly Child Parent

// Parent
<template>
  ...
  <child v-on:event-one="methodOne" v-on:event-two="methodTwo" /> ... </template>

So you passed all v-on events can be found in the $ listeners object when using the Child.

// Child
created () {
  console.log(this.$listeners) // { 'event-one': f(), 'event-two': f() }
}

So, the official examples of computed -> inputListeners is passed when the user base-input component v-on method is gathered.
Then in the form of v-on = "inputListeners" and forwarded to the input box.

Note: v-on = "{a: f ()}" is equivalent to the v-on: a = "f ()"

So when he says that the official website base-input is a transparent wrapper, because it really just forwarded the parent component parameters passed to the input element.

Guess you like

Origin www.cnblogs.com/samve/p/11769080.html
Recommended