Я нашел способ получить эффект, который хотел в итоге.Мое решение может быть не очень масштабируемым, но пока работает!Я передаю дочерний индекс от эмиттера и зацикливаюсь, чтобы размыть каждый компонент, кроме индексированного дочернего индекса.
// ChildOne.vue
// Basically the same for two and three as well except sending corresponding index
// on click event.
// Click event is now sending the index of the component to know which one got clicked.
<template>
<div id="child-one" @click="$emit('toggle-blur', 0)"></div>
</template>
// Parent.vue
// Every child component now gets their separate blur config.
// When child is clicked the index of the child now gets sent to help skip and blur
// the other components.
<template>
<div id="parent">
<child-one v-blur="blurConfig[0]" @toggle-blur="toggleChildBlur"/>
<child-two v-blur="blurConfig[1]" @toggle-blur="toggleChildBlur"/>
<child-three v-blur="blurConfig[2]" @toggle-blur="toggleChildBlur"/>
</div>
</template>
<script>
import ChildOne from './ChildOne'
import ChildTwo from './ChildTwo'
import ChildThree from './ChildThree'
export default {
name: 'Parent',
components: {
ChildOne, ChildTwo, ChildThree
},
methods: {
toggleChildBlur (childIndex) {
// Unblur if click event is outside focused component
if (this.blurConfig[childIndex].isBlurred) {
for (let i = 0; i < this.blurConfig.length; i++) {
this.blurConfig[i].isBlurred = false
}
} else {
for (let i = 0; i < this.blurConfig.length; i++) {
if (i !== childIndex) {
this.blurConfig[i].isBlurred = !this.blurConfig[i].isBlurred
}
}
}
}
},
data () {
return {
// Blur settings for each component
blurConfig: [
{
isBlurred: false,
opacity: 0.2,
filter: 'blur(1.2px)',
transition: 'all .2s linear'
},
{
isBlurred: false,
opacity: 0.2,
filter: 'blur(1.2px)',
transition: 'all .2s linear'
},
{
isBlurred: false,
opacity: 0.2,
filter: 'blur(1.2px)',
transition: 'all .2s linear'
}
]
}
}
}
</script>