vue 判断导航长度点击展开更多

news/2024/7/10 2:02:40 标签: js, vue

vue__0">vue 判断导航长度点击展开更多

html代码

<div v-for="(item,index) in showList" v-show="index<num" :id="index" :key="index"  @click="singleItemList(item.id),changSemester(index)">
            <img :src="item.logo" alt="" style="width:22px;height:22px;float:left">
            <p style="float:left;margin-top:4px;margin-left:10px;">{{ item.name }}</p>
          </div>
          <span style="position: relative;top: 4px;cursor:pointer;" @click="showMore">{{ txt }}</span>

在data里面定义一个 num的长度,和定义一下 txt的初始化

data() {
    return {
      showList:[],
      isShow: true,
      num: 7,
      txt:‘更多’
      }
      }

在methods调用click方法

showMore() {
      this.isShow = !this.isShow
      this.num = this.isShow ? 7 : this.showList.length
      this.txt = this.isShow ? '更多' : '收起'
    },```


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

相关文章

素数、约数、反素数

title: 素数、约数、反素数 date: 2019-07-23 23:56:59 tags: 数论 一、素数 0和1既不是素数也不是合数&#xff0c;最小的素数是2 &#xff08;一&#xff09;素数的判定: 试除法&#xff1a;如果自然数n不能被[2,√n] 内的所有素数整除&#xff0c;那么n是素数。 bool i…

Do not remove docker container until gc process runs

2019独角兽企业重金招聘Python工程师标准>>> Do not remove docker container until gc process runs 博客分类&#xff1a; docker Description The current docker containerizer implementation that is up for review at https://reviews.apache.org/r/23771/ d…

vue点击变色

vue点击变色 <div v-for"(item,index) in showList" v-show"index<num" :id"index" :key"index" :class"{blue:textindex}" class"hi" style" float:left; width:auto;text-align:center;margin-left…

同余和GCD

title: 同余和GCD date: 2019-07-26 16:14:56 tags: 数论 一、模运算 a除以m的余数 r&#xff0c;ra mod ma%m 0≤r≤m-1​&#xff0c;一定存在 akmr,k⌊a/m⌋ a%m的正负由被除数a决定&#xff0c;与m无关&#xff0c;eg. 7%43&#xff0c;-7%4-3 二、同余 同余 (1) 给定…

CNN 在图像分割中的简史:从 R-CNN 到 Mask R-CNN

作者&#xff1a;chen_h微信号 & QQ&#xff1a;862251340微信公众号&#xff1a;coderpai我的博客&#xff1a;请点击这里自从 Alex Krizhevsky, Geoff Hinton, and Ilya Sutskever 成为了 ImageNet 2012 冠军之后&#xff0c;CNN 已经变成了图像分割的标配。实际上&#…

vue el-dialog 点击之后滚动条回到顶部

vue el-dialog 点击之后滚动条回到顶部 记录你当前滚动条的位置 <el-dialog :title"baseTitle" :visible.sync"visible" :before-close"cancelHandle" :close-on-click-modal"false" width"760px" :lock-scroll"f…

AIGrant: 开源AI项目获得 $ 5,000 奖金

作者&#xff1a;chen_h微信号 & QQ&#xff1a;862251340微信公众号&#xff1a;coderpai简书地址&#xff1a;https://www.jianshu.com/p/3b4... 本文翻译来自于 Nat Friedman 我从MIT毕业之后&#xff0c;我知道我喜欢从事开源工——但是我没有钱。毕业后的几个星期内&a…

var const let 有啥区别

一、var声明的变量会挂载在window上&#xff0c;而let和const声明的变量不会 var a 100; console.log(a,window.a); // 100 100 let b 10; console.log(b,window.b);// 10 undefined const c 1; console.log(c,window.c);// 1 undefined 二、var声明变量存在变量提升&am…