Short version:
I am generating an HTML string in a component method, and I cannot figure out how to style this HTML code with cloud CSS because it lacks the data attribute to define the scope.
A slightly longer version:
I have a function called highlight that takes a string and returns an HTML string with all occurrences of the search term highlighted, which means the environment <span class="match"> . However, since I do this manually in a row, this range does not receive the special data attribute that CSS with scope in my Vue component should have, so the only way to create these matches is to make my CSS not covered, which I would not want make. Is there a more Vue-specific way for me to do this? The function is as follows:
// Source: http://stackoverflow.com/a/280805/2874789 function highlight(data, search) { return data.replace( new RegExp("(" + preg_quote(search) + ")", 'gi'), "<span class=match>$1</span>" ); }
(preg_quote is just a function that avoids things that need to be escaped)
Thanks!
source share