vuejs / vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
http://v2.vuejs.org
MIT License
207.98k stars 33.68k forks source link

How to catch $emit event in javascrit #9704

Closed ShravanMweb closed 5 years ago

ShravanMweb commented 5 years ago
vue-bot commented 5 years ago

Hello, your issue has been closed because it does not conform to our issue requirements. In order to ensure every issue provides the necessary information for us to investigate, we require the use of the Issue Helper when creating new issues. Thank you!


你好,你的 issue 不符合我们所要求的格式,因此已被自动关闭。为了确保每个 issue 都提供必需的相关信息,请务必使用我们的 Issue 向导 来创建新 issue,谢谢!

ShravanMweb commented 5 years ago

Version

2.6.2

Reproduction link

https://stackoverflow.com/users/10901207/shravan-sangishetti

Steps to reproduce

How to catch $emit event with v-on: in JavaScript. while doing import MyGrid from 'MyGridcomponemt.vue' import Vue from 'vue' var myDynamicGrid = Vue.extend(MyGrid) var instance = new myDynamicGrid({ propsData: { columns: this.columns,rowsperpage:this.rowsperpage,etc..} }) instance.$mount() // pass nothing //Will append to required place this.$refs.container.appendChild(instance.$el) Here I am able to pass prosData to MyGrid component but how do I catch those $emit events which will trigger by MyGrid component..

What is expected?

Can we catch $emit event in javascript??

How to catch $emit event with v-on: in JavaScript?? My code.. import MyGrid from 'MyGridcomponemt.vue' import Vue from 'vue' var myDynamicGrid = Vue.extend(MyGrid) var instance = new myDynamicGrid({ propsData: { columns: this.columns,rowsperpage:this.rowsperpage,etc..} }) instance.$mount() // pass nothing //Will append to required place this.$refs.container.appendChild(instance.$el) Here I am able to pass prosData to MyGrid component but how do I catch those $emit events which will trigger by MyGrid component..

What is actually happening?

How to catch $emit event with v-on: in JavaScript. Dollowing is My code.. import MyGrid from 'MyGridcomponemt.vue' import Vue from 'vue' var myDynamicGrid = Vue.extend(MyGrid) var instance = new myDynamicGrid({ propsData: { columns: this.columns,rowsperpage:this.rowsperpage,etc..} }) instance.$mount() // pass nothing //Will append to required place this.$refs.container.appendChild(instance.$el) Here I am able to pass prosData to MyGrid component but how do I catch those $emit events which will trigger by MyGrid component..


We are appending MyGrid component to its parent grid multiple times(to make subgrid) here parent gridcomponemt also the same component (MyGrid component). That has been done perfectly but while doing that we can pass only propsData but how to receive $emit event.. please see the following code

How to catch $emit event with v-on: in JavaScript. while doing

import MyGrid from 'MyGridcomponemt.vue' import Vue from 'vue' var myDynamicGrid = Vue.extend(MyGrid) var instance = new myDynamicGrid({ propsData: { columns: this.columns,rowsperpage:this.rowsperpage,etc..} }) instance.$mount() // pass nothing //Will append to required place this.$refs.container.appendChild(instance.$el) Here I am able to pass prosData to MyGrid component but how do I catch those $emit events which will trigger by MyGrid component..

leopiccionia commented 5 years ago

@ShravanMweb https://vuejs.org/v2/api/#vm-on