Answer the question
In order to leave comments, you need to log in
How to click a button using $emit vue.js?
Can't forward click to child element. Reading documentation and don't understand https://vuejs.org/v2/guide/
index.vue
<template>
<div class="fullpage-container">
<div class="page-home">
<div class="button-group">
<b-button-group vertical>
<b-button type="button" v-bind:class="[{active:index ==0}]" @click="moveTo(2)"> // кликнуть эту кнопку
button
</b-button>
</b-button-group>
</div>
<div class="fullpage-wp" v-fullpage="opts" ref="example">
...
<div class="page">
<logo></logo>
</div>
...
</div>
</div>
</div>
</template>
<script>
import Logo from '~/components/Logo.vue'
export default {
data () {
var that = this
return {
index: 0,
opts: {
start: 0,
dir: 'v',
duration: 500,
beforeChange: function (prev, next) {
that.index = next
},
afterChange: function (prev, next) {
}
}
}
},
methods: {
moveTo (index) {
this.$refs.fullpage.$fullpage.moveTo(index, true)
}
},
components: {
Logo
...
}
}
</script>
<template>
<b-button v-on.click="trigger">click</b-button> // этой кнопкой
</template>
<script>
export default {
data () {
....
},
methods: {
trigger: function () {
// this.$emit
}
}
}
</script>
Answer the question
In order to leave comments, you need to log in
In the main component:
In the logo:
trigger: function () {
this.$emit('handleAction')
}
trigger: function () {
this.$emit('handleAction', someParam)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question