admin管理员组文章数量:1316980
I have a simple ponent that uses mixin that's shared across multiple ponents with similar functionality.
When I run it I seem to be getting
Property or method "activeClass" is not defined on the instance but referenced during render.
Here's my mixin
<script>
export default {
data() {
return {
opened: false,
identity: ''
}
},
puted: {
activeClass() {
return {
active: this.opened
};
}
},
created() {
window.EventHandler.listen(this.identity + '-toggled', opened => this.opened = opened);
},
methods: {
toggle() {
window.EventHandler.fire('toggle-' + this.identity);
}
}
}
</script>
and my ponent
<template>
<span class="pointer" :class="activeClass" @click="toggle"><i class="fas fa-search"></i></span>
</template>
<script>
import Trigger from '../../mixins/Trigger';
export default {
data() {
return {
mixins: [Trigger],
data() {
return {
identity: 'language'
}
}
}
}
}
</script>
For some reason I cannot seem to be able to access activeClass
puted property from within the ponent. Any idea why is this happening?
I have a simple ponent that uses mixin that's shared across multiple ponents with similar functionality.
When I run it I seem to be getting
Property or method "activeClass" is not defined on the instance but referenced during render.
Here's my mixin
<script>
export default {
data() {
return {
opened: false,
identity: ''
}
},
puted: {
activeClass() {
return {
active: this.opened
};
}
},
created() {
window.EventHandler.listen(this.identity + '-toggled', opened => this.opened = opened);
},
methods: {
toggle() {
window.EventHandler.fire('toggle-' + this.identity);
}
}
}
</script>
and my ponent
<template>
<span class="pointer" :class="activeClass" @click="toggle"><i class="fas fa-search"></i></span>
</template>
<script>
import Trigger from '../../mixins/Trigger';
export default {
data() {
return {
mixins: [Trigger],
data() {
return {
identity: 'language'
}
}
}
}
}
</script>
For some reason I cannot seem to be able to access activeClass
puted property from within the ponent. Any idea why is this happening?
1 Answer
Reset to default 6Try to move mixin to ponents main scope. Not in data function rerurn
本文标签: javascriptVue component using computed property of the mixinStack Overflow
版权声明:本文标题:javascript - Vue component using computed property of the mixin - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742012765a2413199.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论