| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <template>
- <view>
- {{wordStr}}
- <text style="color: black;" v-if="isShow" @click.stop="openShow">...展开</text>
- <text style="color: black;" v-if="isStop" @click.stop="closeShow">收起</text>
- </view>
- </template>
- <script>
- export default {
- data(){
- return {
- wordStr:"",
- isShow: true,
- isStop: false
- }
- },
- props:['val'],
- created() {
- this.formatHtml(this.val)
- },
- methods:{
- formatHtml(str) {
- console.log(str.length,'长度')
- if(str.length > 50) {
- this.wordStr = str.substr(0,50);
- }
- },
- openShow() {
- this.isShow = false;
- this.isStop = true;
- this.wordStr = this.val;
- },
- closeShow() {
- this.isShow = true;
- this.isStop = false;
- this.formatHtml(this.val);
- }
- }
- }
- </script>
- <style>
- </style>
|