vue实现滑动效果

news/2024/7/10 0:52:24 标签: vue, animation

若实现无缝滚动,可参考https://blog.csdn.net/weixin_38345306/article/details/119917668

:class="{anim: animation}"是实现滚动部分的重要代码
template中的内容

<div class="chart-part-2">
            <ul class="ulList" :class="{anim: animation}">
              <li v-for="item in riskList" :key="index">
                <img src="@img/screen2/subtitle_tag.png">
                <span>{{item.name}}</span>
              </li>
            </ul>
          </div>

script节点中的内容

data(){
animation:false,
riskList:[
   {name:"haha1"},
   {name:"haha2"},
   {name:"haha3"},
   ]
}
created(){
  if(this.riskList.length>1){
        const time=setInterval(this.showMarquee,2000)
      }
}
methods(){
  showMarquee(){
        this.animation=true,
        setTimeout(()=>{
          this.riskList.push(this.riskList[0]);
          this.riskList.shift();
          this.animation=false;
        },340)
        this.$once('hook:beforeDestory',()=>{
          clearInterval(time)
        })
      },
}

style中的内容

.chart-part-2{
      display: flex;
      font-size: 0.8rem;
      font-family: PingFang SC;
      font-weight: 400;
      color: #ffffff;
      align-items: center;
      //justify-content: center;
      overflow: hidden;/**超出部分隐藏 */
      text-overflow: ellipsis;//单行文本超出部分用省略号
      white-space: nowrap;//强制不换行
      width: 100%;
      img{
        width: 1vh;
        height: 1vh;
        margin: 0 1vh;
      }
    }
.ulList{
  list-style: none;
  line-height: 4vh;
  li{
    width: 90%;
    overflow: hidden;/**超出部分隐藏 */
    white-space: nowrap;//强制不换行
    text-overflow: ellipsis;//文本超出部分用省略号
  }
}
.anim{
  transition: all 0.5s ease-out;//实现滚动效果
  margin-top:-30px  
}

http://www.niftyadmin.cn/n/1728592.html

相关文章

python自动化测试自学网_Python自动化测试pytest+Allure

Python自动化报告美化pytestAllure初体验image报告接触过不少&#xff0c;Java自动化测试集成Allure美化报告&#xff0c;将其应用到python中。既然要生成报告&#xff0c;那我们首先需要引入测试框架&#xff0c;pytest是python的第三方测试框架&#xff0c;是基于unittest的扩…

JSON字符串转成json数组

JSONArray jsonArray JSONArray.parseArray(context);

List lambda排序

实体类: public class SC {private Long sid;private String context;public Long getSid() {return sid;}public void setSid(Long sid) {this.sid sid;}public String getContext() {return context;}public void setContext(String context) {this.context context;}Over…

mybatis-plus更新null值

第一种:全局配置 在mybatis-plus配置文件里面进行配置: mybatis-plus:global-config:db-config:field-strategy: not_null field-strategy: not_null不为空就不会更新null,如果改成null就算是null也会对其进行更新 参考文章:https://blog.csdn.net/tplina/article/details/8…

vue,echarts去掉地图上的滑块

visualMap: {show:false,//去掉地图上的滑块 }

mybatis 利用CASE WHEN进行统计或累加

案例: Map<String,Object> queryAgricultureTotal(); <select id"queryAgricultureTotal" resultType"java.util.HashMap">SELECT sum(CASE WHEN type_name LIKE %合作社% THEN 1 ELSE 0 END) AS hezuoshe,sum(CASE WHEN type_name LIKE %家庭…

vue中computed理解,及watch的理解

computed 计算属性 1.可用于快速计算视图&#xff08;View&#xff09;中显示的属性&#xff0c;这些计算将被缓存&#xff0c;并且只在需要时更新。 2.计算属性的内容也可写在方法中&#xff0c;进行调用&#xff0c;虽然结果是相同的&#xff0c;但是性能却有很大差别&#…

springboot核心注解

SpringbootApplication 相当于SpringBootConfiguration、EnableAutoConfiguration、ComponentScan这三个注解的组合 SpringBootConfiguration(Configuration) SpringBootConfiguration继承Configuration注解,他们的功能是一样的标志当前注解时一个配置类,用来代替applicatio…