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文件目录 由于我添加到项目了,所以会显示该项 ...
随机推荐
- Shoot the Bullet ZOJ - 3229有上下界网络流
Code: #include<cstdio> #include<algorithm> #include<vector> #include<queue> ...
- 洛谷P2827 蚯蚓 队列 + 观察
我们不难发现先被切开的两半一定比后被切开的两半大,这样就天然的生成了队列的单调性,就可以省去一个log.所以,我们开三个队列,分别为origin,big,smallorigin, big, small ...
- appium不能获取webview内容的解决办法
在用appium对小猿搜题app进行自动化测试时,准备用page_source打印出文章的xml内容 但是发现只能打印出外部结构内容,实际的文章内容却没有显示 截图如下 查询之后,得知需要通过cont ...
- BZOJ 3158 千钧一发 (最大流->二分图带权最大独立集)
题面:BZOJ传送门 和方格取数问题很像啊 但这道题不能像网格那样黑白染色构造二分图,所以考虑拆点建出二分图 我们容易找出数之间的互斥关系,在不能同时选的两个点之间连一条流量为$inf$的边 由于我们 ...
- 《黑白团团队》第八次团队作业:Alpha冲刺 第四天
项目 内容 作业课程地址 任课教师首页链接 作业要求 团队项目 填写团队名称 黑白团团队 填写具体目标 认真负责,完成项目 团队项目Github仓库地址链接. 第四天 日期:2019/6/18 成员 ...
- java的值传递与引用传递
一. 经常搞不清楚,当一个对象做为参数传入到方法中时,为啥有时候值能被改变,有时候又不会改变,以下说明原因: 1.当传入的参数,在方法中能被改变的为 引用传递 2.当传入的参数,在方法中没被改变的为 ...
- JAVAEE网上商城项目总结
发送邮件实现(使用QQ邮箱发送到指定邮箱) 需要的jar 邮件发送类代码: package util; import java.util.Properties; import javax.mail.A ...
- CF870A Search for Pretty Integers
CF870A Search for Pretty Integers 题意翻译 给出两个整数n,m,a数组有n个数,b数组有m个数.求一个数,这个数的每一位必须在a数组和b数组中至少出现过一次,求符合条 ...
- CF909A Generate Login
CF909A Generate Login 题意翻译 给定两个用空格分隔的字符串,分别取两字符串的任意非空前缀,将两前缀合并为一个新的字符串,求可行字典序最小的字符串. 题目描述 The prefer ...
- iOS开发实践之网络检測Reachability
在网络应用开发中.有时须要对用户设备的网络状态进行实时监控.以至于对用户进行友好提示 或者依据不同网络状态处理不一样的逻辑(如视频播放app,依据当前的网络情况自己主动切换视频清晰度等等).用Reac ...