Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. //Template
  2. <div>
  3. <a href="#">
  4. <h5>{{ productNameStr | truncate(50) }}</h5>
  5. </a>
  6. <template v-if="productNameStr.length < 50">
  7. <p>{{ productDescriptionStr | truncate(50) }}</p>
  8. </template>
  9. </div>
  10.  
  11. //Scripts
  12. props: [
  13. 'productName',
  14. 'productDescription',
  15. ],
  16. data(){
  17. return{
  18. productNameStr: '',
  19. productDescriptionStr: ''
  20. }
  21. },
  22. methods: {
  23. deleteFormattedHTML: function (value) {
  24. let htmlString, div, text
  25. htmlString = value
  26. div = document.createElement("DIV")
  27. div.innerHTML = htmlString
  28. text = div.textContent || div.innerText || ''
  29. div.remove()
  30. return text
  31. }
  32. },
  33. mounted(){
  34. this.productNameStr = this.deleteFormattedHTML(this.productName)
  35. this.productDescriptionStr = this.deleteFormattedHTML(this.productDescription)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement