javascript 从孩子发出事件,听父母vujs

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 从孩子发出事件,听父母vujs相关的知识,希望对你有一定的参考价值。

// in child 

this.$parent.$emit('removeError', event)

// in parent 

this.$on('removeError', function(){
  console.log('Event from parent component emitted')
  this.errorMessage = 0
});


to pass variables example

// in child

let dimensions = {'posX': item.posX, 'posY': item.posY, 'posZ': item.posZ}
this.$parent.$emit( 'dimensions', dimensions)

// in parent

this.$on('dimensions', (dimensions) => alert(dimensions.posX))

以上是关于javascript 从孩子发出事件,听父母vujs的主要内容,如果未能解决你的问题,请参考以下文章