Answer the question
In order to leave comments, you need to log in
How to use components in data?
Importing a component and using it in data ?
components: {
LinkElement: () => import('@/components/elements/LinkElement')
},
data: function () {
return {
departments: [
{
id: 1,
title: this.$t("Отдел по работе с клиентами"),
contacts: [
{
id: 2,
name: this.$t("Email"),
value: `<LinkElement link="#">Link</LinkElement>`
},
<linkelement ...
Answer the question
In order to leave comments, you need to log in
v-html
- only for normal html. And then you need to use it only when you can’t do without it at all.
Vue
works with data, not markup, the markup itself is built on the basis of the data.
In your case, the template itself should be:
...
<component :is="value">{{name}}</component>
...
data
, respectively:...
{
id: 2,
name: this.$t("Email"),
value: `LinkElement`
}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question