哪位大佬能提供一个小demo,不胜感激
3条回答 默认 最新
- CSDN专家-showbo 2021-07-08 14:37关注
有帮助能点采纳吗,谢谢~
效果查看图片:https://img-mid.csdnimg.cn/release/static/image/mid/ask/1625726415615csdnuploader.gif<style> a{color:#f00} </style> <div id="app"> <div>{{word1.length>20&&State['word1']?word1.substring(0,20)+'...':word1}}<a v-bind:style="{display:word1.length>20?'inline':'none'}" v-on:click="toggle" rel="word1">{{State['word1']?'展开':'收起'}}</a></div> <div>{{word2.length>20&&State['word2']?word2.substring(0,20)+'...':word2}}<a v-bind:style="{display:word2.length>20?'inline':'none'}" v-on:click="toggle" rel="word2">{{State['word2']?'展开':'收起'}}</a></div> </div> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script> new Vue({ el: '#app', data: { word1: 'v-bind:style 的对象语法十分直观——看着非常像 CSS,但其实是一个 JavaScript 对象。', word2: '看着非常像 CSS', State: { word1: true, word2: true } }, methods: { toggle(e) { var a = e.target, rel = a.getAttribute('rel'); this.State[rel] = !this.State[rel]; } } }) </script>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用
悬赏问题
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号
- ¥15 基于单片机的靶位控制系统
- ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
- ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?