desc.vue 779 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <view>
  3. {{wordStr}}
  4. <text style="color: black;" v-if="isShow" @click.stop="openShow">...展开</text>
  5. <text style="color: black;" v-if="isStop" @click.stop="closeShow">收起</text>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data(){
  11. return {
  12. wordStr:"",
  13. isShow: true,
  14. isStop: false
  15. }
  16. },
  17. props:['val'],
  18. created() {
  19. this.formatHtml(this.val)
  20. },
  21. methods:{
  22. formatHtml(str) {
  23. console.log(str.length,'长度')
  24. if(str.length > 50) {
  25. this.wordStr = str.substr(0,50);
  26. }
  27. },
  28. openShow() {
  29. this.isShow = false;
  30. this.isStop = true;
  31. this.wordStr = this.val;
  32. },
  33. closeShow() {
  34. this.isShow = true;
  35. this.isStop = false;
  36. this.formatHtml(this.val);
  37. }
  38. }
  39. }
  40. </script>
  41. <style>
  42. </style>