这里用文字举例,图片切换的原理也是一样的
大概思路是:用两个class相同的span分别是切换前后的文字,class相同主要是为了变换前后的文字位置相同。然后用click事件控制它们的显隐。
代码如下:
HTML:
<span class="response" v-show="!showCommentInput" @click="showCommentInput = !showCommentInput">回复</span> <span class="response" v-show="showCommentInput" @click="showCommentInput = !showCommentInput">回复</span>
JS:
data(){ return { showCommentInput = false, } }
CSS:
.response { font-size:14px; color: #3e3e3e; &:hover{ font-weight: bold; } &+.response { font-weight: bold; }
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
以上就是在Vue中如何实现点击后文字变色的详细内容,更多请关注php中文网其它相关文章!
![php中文网最新课程二维码](/static/images/article_wechat2021.jpg?1111)
声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论