this.$refs.layout.$refs.toastRef.show();
|
<template>
<div>
<AppMain @appMainClicked="showToast"/>
<ejs-toast
ref="toastRef"
title="Matt sent you a friend request"
content="Hey, wanna dress up as wizards and ride our hoverboards?"
></ejs-toast>
</div>
</template>
<script>
export default {
name: "Layout",
methods: {
showToast() {
this.$refs.toastRef.show();
}
}
};
</script> |
<template>
<div>
AppMain
<button v-on:click="onClick">Show Toast in child component</button>
</div>
</template>
<script>
export default {
name: "AppMain",
methods: {
onClick: function() {
this.$emit('appMainClicked', '');
}
}
};
</script> |
<template>
<div>
Load
<button v-on:click="onClick">Show Toast from Load component</button>
</div>
</template>
<script>
export default {
name: "Load",
methods: {
onClick: function () {
this.$emit('loadClicked', '');
}
}
};
</script>
|
<template>
<div>
AppMain
<button v-on:click="onClick">Show Toast from AppMain component</button>
<Load @loadClicked="onClick" />
</div>
</template>
<script>
import Load from "./Load";
export default {
name: "AppMain",
components: {
Load
},
methods: {
onClick: function () {
this.$emit('appMainClicked', '');
}
}
};
</script>
|
<template>
<div class="app-main">
<br>AppMain
<br>
<br>
<router-link class="link" :to="{ path: '/load', query: { name: 'Foo' }}">Load</router-link>
<br>
<br>
<router-link class="link" :to="{ path: '/alive', query: { name: 'Foo' }}">KeepAlive</router-link>
<br>
<br>
<router-view @loadClicked="onClick"/>
</div>
</template>
<script>
export default {
name: "AppMain",
methods: {
onClick: function() {
this.$emit("appMainClicked", "");
}
}
};
</script>
|
<template>
<div class="load">
Load
<button v-on:click="onClick">Show Toast from Load component</button>
</div>
</template>
<script>
export default {
name: "Load",
methods: {
onClick: function() {
this.$emit("loadClicked", "");
}
}
};
</script>
|
<style>
.e-toast {
z-index: 1007 !important;
}
</style> |