vue 移动端项目,动态控制div距离底部的距离
<template>
<div class="details">
<com-nav-bar title="保险详情">
<i class="iconfont icon-xiangzuo" slot="left"></i>
</com-nav-bar>
<div class="details-scroll-wrapper" ref="scrollWrapper" :style="{bottom:bottom + 'px'}"> //动态添加样式
<div class="details-scroll-inner" :style="{paddingBottom:paddingBottom + 'px'}">
<div :class="[productInfo.tips?'cate':'cates']">
<span>{{productInfo.tips}}</span>
</div>
</div>
</div>
</div>
<div class="btn-bottom" ref="btnDetails"> //先算出这个的高度(因为这个高度不是固定的,所以需要让上面的div距离底部的就需要是动态计算出来)
<div class="btn-info">
<div style="display:flex;">
<div style="min-width:95px;margin-top:4px;">
<span class="agree" @click="choos"><i class="iconfont " :class="{'icon-weixuanzhong':!checked,'icon-xuanzhong1':checked}"></i>我已阅读:</span>
</div>
<div>
<span class="links" v-for="item in linksData" @click='goDetails(item.key,item.title,productInfo.id)'>《{{item.title}}》</span>
</div>
</div>
</div>
<div class="btn">
<button>{{productInfo.premium}}</button>
<button @click="goInsure(productInfo.code)">立即投保</button>
</div>
</div>
</div>
</template>
<script>
import BScroll from 'better-scroll'
import urls from '@/api/urls'
export default {
data() {
return {
paddingBottom: 0,
bottom:0,
}
},
created() {
this.id = this.$route.query.id
this.getInfo()
this.$store.dispatch("setpayData", {});
this.$store.dispatch('setorderData', {});
},
methods: {
// 获取产品详情
getInfo() {
this.$loadingStart()
this.$http(urls.productInfo, {
productCode: this.id,
})
.then(res => {
let that = this
this.$nextTick(() => {
this.tabTop = this.$refs.tabHeader.offsetTop
this.paddingBottom = this.$refs.scrollWrapper.clientHeight -
parseInt(getComputedStyle(this.$refs.sectionWrapper).paddingTop) -
this.$refs.tabHeader.clientHeight -
this.$refs.evaluate.clientHeight
let sall = document.querySelectorAll("div.introduce span.info img");
for(let i = 0, len = sall.length; i < len; i++) {
let interval = setInterval(function() {
if(sall[i].clientHeight != 0) {
that.scroll.refresh()
clearInterval(interval)
}
}, 100)
// sall[i].onload = function() {
// that.scroll.refresh()
// }
}
this.bottom=this.$refs.btnDetails.clientHeight //在这里获取到底部的高度,然后赋值到bottom
console.log(this.$refs.btnDetails.clientHeight);
})
})
.catch(err => {
this.$loadingEnd()
this.$errorHandler(err)
})
}
},
mounted() {
this.scroll = new BScroll(this.$refs.scrollWrapper, {
click: true,
probeType: 3,
pullUpLoad: {
threshold: 60,
},
})
this.scroll.on('scroll', pos => {
const {
y
} = pos
const scrollY = -y
// 锚点实时切换
const evaluateTop =
this.$refs.evaluate.offsetTop -
this.$refs.tabHeader.clientHeight -
parseInt(getComputedStyle(this.$refs.sectionWrapper).paddingTop)
const buyTop =
this.$refs.buy.offsetTop -
this.$refs.tabHeader.clientHeight -
parseInt(getComputedStyle(this.$refs.sectionWrapper).paddingTop)
this.showTop = scrollY > this.tabTop
if(scrollY >= evaluateTop) {
this.active = 2
} else if(scrollY >= buyTop) {
this.active = 1
} else {
this.active = 0
}
})
},
beforeDestroy() {
this.scroll.destroy();
}
}
</script>
<style scoped lang="less" rel="stylesheet/less">
</style>
vue 移动端项目,动态控制div距离底部的距离的更多相关文章
- 从零开始搭建vue移动端项目到上线的步骤
初始化项目 1.在安装了node.js的前提下,使用以下命令 npm install --g vue-cli 2.在将要构建项目的目录下 vue init webpack myproject(项目目录 ...
- 从零开始搭建vue移动端项目到上线
先来看一波效果图 初始化项目 1.在安装了node.js的前提下,使用以下命令 npm install --g vue-cli 2.在将要构建项目的目录下 vue init webpack mypro ...
- Vue移动端项目总结
使用Vue项目写了一个移动端项目,然后又把项目硬生生的抽离了组件,一直忙着写RN项目没有时间总结心得,今天上午终于下定决心,写点总结. 1.position:absolute: 定位的时候不同手机的浏 ...
- Vue移动端项目模板
一个集成移动端开发插件的Vue移动端模板包含1.css: 使用stylus开发css 集成reset样式文件 修改UI组件文件 统一样式处理(如主题色等)2.UI组件 使用热门的vant与mint-u ...
- vue 移动端项目总结(mint-ui)
跨域解决方案 config/dev.env.js 'use strict' const merge = require('webpack-merge') const prodEnv = require ...
- 17.vue移动端项目二
FilmList.vue 电影列表 <template> <div class="mz-film-list"> <!-- 正在热映 https://m ...
- vue 移动端项目切换页面,页面置顶
之前项目是pc端是使用router的方式实现置顶的 //main.js router.afterEach((to, from, next) => { window.scrollTo(0, 0) ...
- vue PC端项目中解决userinfo问题
在vue2 中用脚手架建立的项目,后端提供接口获取数据.在公司做第一个项目的时候不清楚公司里的对接流程,结果后续代码被一个接口整的乱七八糟,这个接口是获取用户信息的接口——'usre/info'. 如 ...
- 将Vue移动端项目打包成手机app---HBuilder
将移动端页面打包成app 1.使用 HBuilder 直接编译打包 点击左上角 文件>打开目录>选择目录 选择用Webpack打包好的dist文件目录 由于我添加到项目了,所以会显示该项 ...
随机推荐
- linu问题集锦
问题1 系统卡 慢 执行命令延迟/var/spool/mail下root文件过大导致/var磁盘空间92% cd / && du | sort -n | tail -n 10 查看排名 ...
- JavaScript进阶【三】JavaScript面向对象的基础知识复习
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- vue 面试题 2019
vue核心知识点 1.对于Vue是一套渐进式框架的理解 渐进式代表的含义是:主张最少. Vue可能有些方面是不如React,不如Angular,但它是渐进的,没有强主张,你可以在原有大系统的上面,把一 ...
- js操作url参数
function getQueStr(url, ref) //获取参数值 { var str = url.substr(url.indexOf('?') + 1); if (str.indexOf(' ...
- javaSE常用的英语单词
1.continut 使......继续 2.break 打破 3.switch 开关:转换:鞭子 4.case 实例:情况:箱 5.Object 目标:物体 6.Class 阶级:班级:种类 7.p ...
- Linux(CentOS 6.4)系统中安装mplayer
整了一个上午终于把mplayer安装上了,我的系统是centos 6.4,真是不容易啊! 一.准备工作 需要的安装包及下载地址:1.mplayer源代码包(MPlayer-1.0rc4.tar.bz2 ...
- Django入门--模板变量、过滤器及静态文件
一.模板变量 我们登录页面后,在页面上会显示姓名等信息,姓名就是模板变量,用来显示登陆者的名字,Django对这些数据进行处理后,返回给前端页面,前端页面进行渲染. 1.模板变量语法规则 1)在htm ...
- CodeForcesGym 100548G The Problem to Slow Down You
The Problem to Slow Down You Time Limit: 20000ms Memory Limit: 524288KB This problem will be judged ...
- 说说sys_context函数
select SYS_CONTEXT('USERENV', 'TERMINAL') terminal, SYS_CONTEXT('USERENV', 'LANGUAGE') langua ...
- net--技术栈(大图)