vue-property-decorator icon indicating copy to clipboard operation
vue-property-decorator copied to clipboard

How does @emit guarantee the execution order of functions

Open Rabbitzzc opened this issue 4 years ago • 0 comments

in vue2.x

// Parent
<div @hello="sayHello"></div> 
export default {
	method: {
		sayHello() {
			console.log('hello')
		}
	}
}
// Child
export default {
	methods: {
		sayWorld() {
			console.log('hi')
      this.$emit('hello')
      console.log('world')
		}
	}
}

Trigger the event, output hi hello world

in vue.2x by ts

// Child
@Component
export default class World extend Vue{
	@Emit()
	sayWorld() {
    console.log('hi')
    console.log('world')
  }
}

Trigger the event, outpu hello hi world

I want to know how @emit guarantees execution order hi hello world

Rabbitzzc avatar Jul 05 '19 08:07 Rabbitzzc