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文件目录 由于我添加到项目了,所以会显示该项 ...
随机推荐
- vue 2.0 购物车小球抛物线
备注:此项目模仿 饿了吗.我用的是最新的Vue, 视频上的一些写法已经被废弃了. 布局代码 <div class="ball-container"> <trans ...
- C++学习笔记(转)
http://www.cnblogs.com/maowang1991/p/3290321.html 以下内容为自己一年多的C++学习心得,纯原创,转载请注明源地址. 一年多的C++学习过程中,自己阅读 ...
- 00069_DateFormate
1.DateFormate类概述 (1)DateFormat 是日期/时间格式化子类的抽象类,它以与语言无关的方式格式化并解析日期或时间.日期/时间格式化子类(如 SimpleDateFormat类) ...
- 洛谷——P2440 木材加工
https://www.luogu.org/problem/show?pid=2440#sub 题目背景 要保护环境 题目描述 题目描述: 木材厂有一些原木,现在想把这些木头切割成一些长度相同的小段木 ...
- K - The Unique MST
K - The Unique MST #include<iostream> #include<cstdio> #include<cstring> #include& ...
- windows、linux劫持技术
windows系统以下能够利用detours劫持 realse 模式劫持,调试的程序不能够 函数劫持能够实现的效果. 函数的劫持原理 我们怎样实现-detours detours是微软亚洲研究院出品 ...
- hdu2767 Proving Equivalences,有向图强联通,Kosaraju算法
点击打开链接 有向图强联通,Kosaraju算法 缩点后分别入度和出度为0的点的个数 answer = max(a, b); scc_cnt = 1; answer = 0 #include<c ...
- 2016.02.25,英语,《Vocabulary Builder》Unit 02
ag:来自拉丁语do.go.lead.drive,an agenda是要做事情的清单,an agent是代表他们做事的人,同时也是为他人做事的机构.拉丁语litigare包括词根lit,即lawsui ...
- $scope angular在controller之外调用
1.定义 var m = angular.module('ddd',[]); m.controller('ctrl',['$scope',function ($scope) { }]); 2.外部调用 ...
- Swift EventKit的初学者指南–请求权限
EventKit为获取和操作用户日历事件和提醒提供了一系列的类.在下面的教程中,我的目标是带领你走出利用EventKit建立一个应用程序的第.我的目标是带领你迈出利用EventKit建立一个应用程序的 ...