2

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

1 Answer 1

2

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>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.