vue 五星评价插件
2024-09-06 07:34:03
html:
<div class="starBox" ref="star1">
<div class="star" v-for="(item,index) in starArr1" :key="index" @click="starClick1(index)">
<img :src="'../../static/images/'+item.imgSrc">
</div>
</div>
js:
export default {
data () {
return {
starArr1: [{imgSrc: 'star1.png'}, {imgSrc: 'star1.png'}, {imgSrc: 'star1.png'}, {imgSrc: 'star1.png'}, {imgSrc: 'star1.png'}]
}
},
methods: {
starClick1 (index) {
this.starArr1.forEach((element, i) => {
this.$set(element, 'imgSrc', 'star1.png')
if (i <= index) {
this.$set(element, 'imgSrc', 'star2.png')
}
})
this.commentScore[0] = index + 1
}
}
}
css:
.starBox {
display: flex;
display: -webkit-flex;
}
.starActive {
color: red;
}
.star img {
width: 40px;
height: 20px;
}
最新文章
- Object-c 内存管理
- Composer根据Name显示与隐藏
- android 在使用studio 编写百度地图中遇到APP Scode码校验失败 问题
- Multiples of 3 and 5
- JAXB 2.0 API is being loaded from the bootstrap classloader
- iOS开发HTTPS实现之信任SSL证书和自签名证书
- zoj 3755
- python基础教程第4章——字典
- phantomjs初次认识
- hdu_4651_Partition(公式)
- CountDownLatch的实现原理
- C语言学生管理系统(增进版)
- SQL Server读写分离之发布订阅
- [Swift]LeetCode856. 括号的分数 | Score of Parentheses
- php 一行代码解决二维数组去重
- linux下的网络通信设置:openssh、PuTTY、tightVNC
- linux下如何解除被占用的端口号
- centos7安装redis单机版
- PHP——语句和时间函数
- JS-制作留言提交系统(支持ctrl+回车)
热门文章
- 【python】遇到的错误
- finalize的作用
- ES6 学习 -- 解构赋值
- 在Linux(centos)下,安装Apache和PHP环境
- canvas插入图片设置背景,渐变
- Python 输入字符串找(String)下标 没有返回-1
- drop database出现1010
- leetcode-240-搜索二维矩阵②
- Sublime text2 + cygwin编译C++
- hexo next主题中遇到的关于require的timeout的问题。Uncaught Error: Load timeout for modules: