Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore an html element in vuejs

How to prevent Vue.js from running code within the < code > tags produced by markdown? It's a Laravel 5.5 + Vue.js 2.x project with 'andreasindal/laravel-markdown' package for markdown. The code that's Vue is trying to run is actually a Laravel Blade directive and it seems that Blade itself doesn't try to process it (since I'm getting a Vue error regarding this in the console).

{{ session('notificationType') }}

I tired modifying the Parsedown.php class (which is used by 'andreasindal/laravel-markdown') to replace all the '{' with the HTML ASCII characters. The replacement did work, but Vue still processed those.

like image 313
Alexander Avatar asked Nov 28 '17 13:11

Alexander


People also ask

How do you hide an element in Vue?

When using v-show="false" the element is rendered in the DOM, however, Vue applies the inline style display: none that hides the element completely. Also, do not forget about the powerful :class binding if you'd like more visibility customization. To hide the element but keep its space use :class="{ invisible: !

How do I select HTML element in Vue?

querySelector in Vue We can use querySelector to select an HTML element that returns the first element within the document that matches a specified selector.

Does Vue sanitize HTML?

What if you want something in between? This is where vue-sanitize comes in. Not only will it allow you to use a whitelist of "safe" HTML tags, it will remove disallowed tags rather than escaping them.

What is $t in Vue?

Vuex is a state management pattern for vue. js. $t is the injected method from vue. js or Vue.


1 Answers

If you do not want Vuejs to evaluate anything inside an HTML element you can use the v-pre directive as:

<code v-pre> {{ name }} </code>

In the above example vue will ignore everything inside the tags so, the name variable won't be evaluated and everything will be rendered as is.

* more on v-pre

like image 85
samayo Avatar answered Oct 31 '22 23:10

samayo