0

How can I display the title with spans as HTML not plain text.

Code:

spanTitle() {
    return this.title.replace(/([A-Za-z0-9'<>/]+)/g, '<span>$1</span>');
}

{{ spanTitle }}

this.title = "Upcomming Events"

spanTitle currently displays as:

<span>Upcomming</span> <span>Events</span>
BennKingy
  • 1,265
  • 1
  • 18
  • 43

2 Answers2

1

To fix the issue, I used the v-html directive

BennKingy
  • 1,265
  • 1
  • 18
  • 43
1

you can do using ,

but a better way to do is

spanTitle() {
    return this.title.replace(/([A-Za-z0-9'<>/]+)/g, $1);
}

and use span in template like

<span> {{ spanTitle  }} </span>
meet vaghsiya
  • 200
  • 12