Zakari
Zakari

Reputation: 743

vue - interpolation html value

there is a v-data-table with server side pagination, where I used a formatter for a specific column as described to this topic.

the need is to replace it with HTML and not plain text. For example my function is like :

    formatCurrency (value) {
        return '<strong>' + value + '</strong>';
        //'<v-icon dark small>tick-outline</v-icon>' + value;
    },

when I using this getting the pure HTML.... as :

enter image description here

Upvotes: 2

Views: 756

Answers (1)

Nikola Pavicevic
Nikola Pavicevic

Reputation: 23490

Try to use v-html directive :

new Vue({
  el: '#demo',
  data() {
    return {
      price: 555.33
    }
  },
  methods: {
    formatCurrency (value) {
      return '<strong>' + value + '</strong>';
        //'<v-icon dark small>tick-outline</v-icon>' + value;
    },
  }
})

Vue.config.productionTip = false
Vue.config.devtools = false
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
 <div v-html="formatCurrency(price)"></div> 
</div>

Upvotes: 2

Related Questions