亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue/js實(shí)現(xiàn)頁面自動(dòng)往上滑動(dòng)效果

 更新時(shí)間:2022年04月06日 12:20:48   作者:紫菀檀ss  
這篇文章主要為大家詳細(xì)介紹了vue/js實(shí)現(xiàn)頁面自動(dòng)往上滑動(dòng)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue/js實(shí)現(xiàn)頁面自動(dòng)往上滑動(dòng)的具體代碼,供大家參考,具體內(nèi)容如下

最近做的新項(xiàng)目中要求讓看不見的內(nèi)容自動(dòng)往上滑動(dòng)一定的距離,使之可以看到,下面我來分享一下。

效果圖:

我主要是使用 scrollTop 來做的往上滑動(dòng)的功能,使用 animate 函數(shù)使之有一定的動(dòng)畫效果。有一個(gè)注意點(diǎn)就是要滾動(dòng)的元素是父級(jí)標(biāo)簽,比如我下面列舉的代碼:id=“scrollbody” 是放在父級(jí)標(biāo)簽?zāi)抢锏?,它包裹著多?xiàng) class=“item” ,如果還是不懂的話,就看使用了v-for在哪個(gè)標(biāo)簽使用,然后我們就獲取它的父標(biāo)簽即可。

下面是我的相關(guān)代碼,大家可以參考:

1、html代碼

<div class="bodyblockcons" :style="'padding-top:'+heightHeader+'px'">
? ? ? <div class="content">
? ? ? ? <div class="title" id="titles">
? ? ? ? ? <span class="name">名稱</span>
? ? ? ? ? <span class="num">數(shù)量</span>
? ? ? ? ? <span class="price plt">價(jià)格</span>
? ? ? ? </div>
? ? ? ? <div class="item-content">
? ? ? ? ? <div class="ct-content" id="scrollbody" :style="ShowKey?'height:'+boHeights+'px;':''" @click="enterNull">
? ? ? ? ? ? <div
? ? ? ? ? ? ? class="item"
? ? ? ? ? ? ? v-for="(item,index) in newList"
? ? ? ? ? ? ? :key="index+item"
? ? ? ? ? ? ? @click.stop="enterNull"
? ? ? ? ? ? ? :id="'itemID'+index"
? ? ? ? ? ? >
? ? ? ? ? ? ? <div class="name">{{item.Product}}</div>
? ? ? ? ? ? ? <!--紅色字體樣式 colorRed -->
? ? ? ? ? ? ? <div class="num">
? ? ? ? ? ? ? ? <div class="nums">
? ? ? ? ? ? ? ? ? {{item.numAccount}}
? ? ? ? ? ? ? ? ? <span
? ? ? ? ? ? ? ? ? ? :class="(item.ProductUnit==item.StockProductUnit)?'':'colorRed'"
? ? ? ? ? ? ? ? ? >{{item.ProductUnit}}</span>
? ? ? ? ? ? ? ? </div>
? ? ? ? ? ? ? ? <div class="row">({{item.barAccount}}條)</div>
? ? ? ? ? ? ? </div>
? ? ? ? ? ? ? <!-- colorFD 藍(lán)色邊框 -->
? ? ? ? ? ? ? <div
? ? ? ? ? ? ? ? :class="(indid==item.id)?'price colorFD':'price'"
? ? ? ? ? ? ? ? @click.stop="enterItem(item,index,$event)"
? ? ? ? ? ? ? >
? ? ? ? ? ? ? ? <!-- pribgc 背景色(全選) -->
? ? ? ? ? ? ? ? <span
? ? ? ? ? ? ? ? ? :class="!isTab&&(indid==item.id)&&!item.state&&isClear?'pri pribgc':'pri'"
? ? ? ? ? ? ? ? >{{item.UnitPrice}}</span>
? ? ? ? ? ? ? ? <span class="icon" v-if="!isTab&&(indid==item.id)&&!item.state&&!isClear"></span>
? ? ? ? ? ? ? </div>
? ? ? ? ? ? </div>
? ? ? ? ? </div>
? ? ? ? </div>
? ? </div>
</div>

2、js文件

import $ from '../../../../static/js/jquery-3.3.1.min.js';
import {
? mapState
} from "vuex";
let timer;
export default {
? data() {
? ? return {
? ? ? name: '填價(jià)格',
? ? ? newList: [], // 合并填單價(jià)
? ? ? keyHeight: 0,
? ? ? boHeights: 0,
? ? }
? },
? computed: {
? ? marginTop() {
? ? ? let height = 0;
? ? ? let result = (1.877 + 1.621 + 0.426 * 2 - 2.5);

? ? ? let restheight = hotcss.rem2px(result, window.innerWidth);
? ? ? console.log('marginTop---------------->', restheight);
? ? ? return restheight;
? ? },
? ? ...mapState({
? ? ? detailsInfo: state => state.detailsInfo.all,
? ? }),
? },
? methods: {
? ? // 確定按鈕,只是用于定位到下一行
? ? makesure() {
? ? ? console.log('makesure-->val', this.isNull);
? ? ? console.log('保存。。。。');
? ? ? let _this = this;
? ? ? _this.inputVal = '';
? ? ? _this.inds = _this.inds + 1;
? ? ? _this.indid = _this.indid + 1;
? ? ? if (_this.inds < _this.newList.length - 1 || _this.inds == _this.newList.length - 1) {
? ? ? ? _this.getTop(); // 在這里調(diào)用滑動(dòng)的方法
? ? },
? ? getTop() {
? ? ? $('#scrollbody').animate = "";
? ? ? let tops = $('#itemID' + this.inds).offset();
? ? ? let tps = tops['top']; ?// 獲取當(dāng)前框距離頂部的距離
? ? ? let height = $('#itemID' + this.inds).outerHeight(); ?// 獲取當(dāng)前框的高度
? ? ??
? ? ? console.log('滑動(dòng)的高度--->', height * (this.inds - (indss - 1)))
? ? ? if (tps > this.boHeights) { ?// 如何當(dāng)前框的距離頂部的距離大于某個(gè)值(該值可以自動(dòng)動(dòng)態(tài)設(shè)置),那么就讓它往上滑動(dòng)
? ? ? ? console.log('-------------->', tps);
? ? ? ? $('#scrollbody').animate({
? ? ? ? ? scrollTop: height * (this.inds*2) ?// 注意:這里的數(shù)值一定要?jiǎng)討B(tài)變化,不然只會(huì)滑動(dòng)一次而已
? ? ? ? }, 300 /*scroll實(shí)現(xiàn)定位滾動(dòng)*/ ); /*讓整個(gè)頁面可以滾動(dòng)*/
? ? ? }
? ? },
? },
? mounted() {
? ? console.log('proList------->111', this.proList);
? ?this.newList ?= [...this.detailsInfo.settlmentList]
? },
}

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • JS冒泡事件與事件捕獲實(shí)例詳解

    JS冒泡事件與事件捕獲實(shí)例詳解

    這篇文章主要介紹了JS冒泡事件與事件捕獲,結(jié)合實(shí)例形式分析了javascript冒泡的原理與阻止冒泡的相關(guān)操作技巧,需要的朋友可以參考下
    2016-11-11
  • 關(guān)于layui的按鈕禁用與恢復(fù)方式

    關(guān)于layui的按鈕禁用與恢復(fù)方式

    這篇文章主要介紹了關(guān)于layui的按鈕禁用與恢復(fù)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • js中的referrer返回上一頁使用介紹

    js中的referrer返回上一頁使用介紹

    js中的referrer想必大家并不陌生吧,在本文將為大家詳細(xì)介紹其是如何使用的,感興趣的朋友可以參考下,希望對(duì)大家有所幫助
    2013-09-09
  • javascript頁面渲染速度測試腳本分享

    javascript頁面渲染速度測試腳本分享

    這篇文章主要介紹了javascript頁面渲染速度測試腳本,計(jì)算瀏覽器渲染HTML頁面所需要的時(shí)間,需要的朋友可以參考下
    2014-04-04
  • javascript簡單比較日期大小的方法

    javascript簡單比較日期大小的方法

    這篇文章主要介紹了javascript簡單比較日期大小的方法,涉及JavaScript針對(duì)日期的轉(zhuǎn)換與判定操作技巧,需要的朋友可以參考下
    2016-01-01
  • 使用JS實(shí)現(xiàn)jQuery的addClass, removeClass, hasClass函數(shù)功能

    使用JS實(shí)現(xiàn)jQuery的addClass, removeClass, hasClass函數(shù)功能

    這篇文章主要介紹了使用JS實(shí)現(xiàn)jQuery的addClass, removeClass, hasClass函數(shù)功能,需要的朋友可以參考下
    2014-10-10
  • 一文教會(huì)你從零開始畫echarts地圖

    一文教會(huì)你從零開始畫echarts地圖

    ECharts是一個(gè)使用JavaScript實(shí)現(xiàn)的開源可視化庫,涵蓋各行業(yè)圖表,滿足各種需求,下面這篇文章主要給大家介紹了如何從零開始畫echarts地圖的相關(guān)資料,需要的朋友可以參考下
    2022-04-04
  • JS中call()和apply()的功能及用法實(shí)例分析

    JS中call()和apply()的功能及用法實(shí)例分析

    這篇文章主要介紹了JS中call()和apply()的功能及用法,結(jié)合實(shí)例形式詳細(xì)分析了JS中call()和apply()的功能、區(qū)別、使用方法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下
    2019-06-06
  • JavaScript實(shí)現(xiàn)簡單拖拽效果

    JavaScript實(shí)現(xiàn)簡單拖拽效果

    這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)簡單拖拽效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • JS實(shí)現(xiàn)3D圖片旋轉(zhuǎn)展示效果代碼

    JS實(shí)現(xiàn)3D圖片旋轉(zhuǎn)展示效果代碼

    這篇文章主要介紹了JS實(shí)現(xiàn)3D圖片旋轉(zhuǎn)展示效果代碼,可實(shí)現(xiàn)頁面元素的3D旋轉(zhuǎn)變換效果,涉及JavaScript動(dòng)態(tài)數(shù)學(xué)運(yùn)算的相關(guān)技巧,需要的朋友可以參考下
    2015-09-09

最新評(píng)論