
app点击返回按钮出现提示框,确定的时候才返回
不加flag变量控制的话,点击返回,会死循环弹出提示框。
flag: true//是否弹出返回提示框
onBackPress() {
console.log("点击了返回");
if (this.flag) {
uni.showModal({
title: "温馨提示",
content: "是否确定退出?",
success: (res) => {
if (res.confirm) {
console.log("确定返回");
this.flag = false
uni.navigateBack({
delta: 1
})
return true
} else {
this.flag = true
console.log("取消");
return true
}
}
})
return true
}else{
return false
}
},
不加flag变量控制的话,点击返回,会死循环弹出提示框。
flag: true//是否弹出返回提示框
onBackPress() {
console.log("点击了返回");
if (this.flag) {
uni.showModal({
title: "温馨提示",
content: "是否确定退出?",
success: (res) => {
if (res.confirm) {
console.log("确定返回");
this.flag = false
uni.navigateBack({
delta: 1
})
return true
} else {
this.flag = true
console.log("取消");
return true
}
}
})
return true
}else{
return false
}
},
收起阅读 »

通告栏最简使用方案
多行上下轮播 使用swiper 代码如图
单行轮播可以使用css动画来实现
.notice {
position: absolute;
display: block;
white-space: nowrap;
padding-left: 100%;
animation: notice 10s 0s linear infinite both;
animation-play-state: paused;
/ 设置时间 /
animation-duration: 10s;
animation-play-state: running;
animation-delay: -3.51s;
}
@keyframes notice {
100% {
transform: translate3d(-100%, 0, 0);
}
}
多行上下轮播 使用swiper 代码如图
单行轮播可以使用css动画来实现
.notice {
position: absolute;
display: block;
white-space: nowrap;
padding-left: 100%;
animation: notice 10s 0s linear infinite both;
animation-play-state: paused;
/ 设置时间 /
animation-duration: 10s;
animation-play-state: running;
animation-delay: -3.51s;
}
@keyframes notice {
100% {
transform: translate3d(-100%, 0, 0);
}
}
收起阅读 »

判断进入登录页还是首页
页面初始化的时候,未登录跳转到登录页的话,会闪一下pages.json里的第一个首页。
而使用首页v-if来切换登录页面模板的话,tabbar又会闪一下。哪怕是在app.vue里写了uni.hideTabbar(),还是会闪。
最终只能在pages.json第一项搞个空白页,然后redirect到登录页了,看起来自然一点。
(我测试的环境是微信小程序,使用的hbuilderX是2.9.8)
页面初始化的时候,未登录跳转到登录页的话,会闪一下pages.json里的第一个首页。
而使用首页v-if来切换登录页面模板的话,tabbar又会闪一下。哪怕是在app.vue里写了uni.hideTabbar(),还是会闪。
最终只能在pages.json第一项搞个空白页,然后redirect到登录页了,看起来自然一点。
(我测试的环境是微信小程序,使用的hbuilderX是2.9.8)
收起阅读 »
vue nvue canvas video的吐槽
商品详情有个canvas画海报的功能,一开始没什么的
一天商品详情被要求支持短视频video,也没啥的
video在vue swiper中不能轮播,嗯开始有问题了
官方的建议是使用nvue
切换了一天,vue swiper video很完美
开心。。。。。
下班。。。。。
。。。。。。。
半路
测试说APP无法生成海报
卧槽,nvue不支持canvas
so,我现在又在电脑面前找解决方案
兄弟们
九九孩子
官方的NvueCanvasDemo不是我想要的
看来只能麻烦后台了
商品详情有个canvas画海报的功能,一开始没什么的
一天商品详情被要求支持短视频video,也没啥的
video在vue swiper中不能轮播,嗯开始有问题了
官方的建议是使用nvue
切换了一天,vue swiper video很完美
开心。。。。。
下班。。。。。
。。。。。。。
半路
测试说APP无法生成海报
卧槽,nvue不支持canvas
so,我现在又在电脑面前找解决方案
兄弟们
九九孩子
官方的NvueCanvasDemo不是我想要的
看来只能麻烦后台了
收起阅读 »
关于新版本canvasGetImageData报错的解决方法
蓝牙打印一直用到uni.canvasGetImageData生成画布,更新新版本后一直报错,现在使用uni.canvasPutImageData替代
uni.canvasPutImageData({
canvasId: 'prite_area_canvas',
x: 0,
y: 0,
width: canvasWidth,
height: canvasHeight,
data: command.getData(),
success: function(res) {
console.log('success')
command.setBitmap(res)
},
fail:function(){
console.log('fail')
},
complete: function() {
// command.setPrintAndFeedRow(3);
console.log('complete')
that.prepareSend(command.getData());
}
})
蓝牙打印一直用到uni.canvasGetImageData生成画布,更新新版本后一直报错,现在使用uni.canvasPutImageData替代
uni.canvasPutImageData({
canvasId: 'prite_area_canvas',
x: 0,
y: 0,
width: canvasWidth,
height: canvasHeight,
data: command.getData(),
success: function(res) {
console.log('success')
command.setBitmap(res)
},
fail:function(){
console.log('fail')
},
complete: function() {
// command.setPrintAndFeedRow(3);
console.log('complete')
that.prepareSend(command.getData());
}
})
收起阅读 »

Vue.js自定义垂直/水平滚动条组件|vue模拟滚动条
介绍
VScroll滚动条 基于vuejs2.x构建的美化XY轴滚动条组件。支持原生滚动条、鼠标移出是否隐藏滚动条、自定义滚动条尺寸、颜色及层级等功能。拥有漂亮且流畅的滚动体验!

参数配置
props: {
// 是否显示原生滚动条
native: Boolean,
// 是否自动隐藏滚动条
autohide: Boolean,
// 滚动条尺寸
size: { type: [Number, String], default: '' },
// 滚动条颜色
color: String,
// 滚动条层级
zIndex: null
},
快速引入
在main.js中引入组件。
import VScroll from './components/vscroll';
Vue.use(VScroll);
使用组件
<!-- 支持原生滚动条 -->
<v-scroll native>
<img src="https://cn.vuejs.org/images/logo.png" />
<p>这里是自定义内容。这里是自定义内容。这里是自定义内容。</p>
</v-scroll>
<!-- 参数配置 -->
<v-scroll autohide size="15" color="#00a1e0" zIndex="2021">
<img src="https://cn.vuejs.org/images/logo.png" />
<p>这里是自定义内容。这里是自定义内容。这里是自定义内容。</p>
</v-scroll>
实现过程
// vscroll模板
<template>
<div class="vui__scrollbar" ref="ref__box" @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave" v-resize="handleResize">
<div :class="['vscroll__wrap', {native: native}]" ref="ref__wrap" @scroll="handleScroll">
<div class="vscroll__view" v-resize="handleResize"><slot /></div>
</div>
<!-- //水平|垂直滚动条 -->
<div :class="['vscroll__bar vertical', {ishide: !isShow}]" @mousedown="handleClickTrack($event, 0)" :style="{'width': parseInt(size)>=0 ? parseInt(size)+'px' : '', 'z-index': parseInt(zIndex)>=0 ? parseInt(zIndex) : ''}">
<div class="vscroll__thumb" ref="ref__barY" :style="{'background': color, 'height': barHeight+'px'}" @mousedown="handleDragThumb($event, 0)"></div>
</div>
<div :class="['vscroll__bar horizontal', {ishide: !isShow}]" @mousedown="handleClickTrack($event, 1)" :style="{'height': parseInt(size)>=0 ? parseInt(size)+'px' : '', 'z-index': parseInt(zIndex)>=0 ? parseInt(zIndex) : ''}">
<div class="vscroll__thumb" ref="ref__barX" :style="{'background': color, 'width': barWidth+'px'}" @mousedown="handleDragThumb($event, 1)"></div>
</div>
</div>
</template>
/**
* @Desc VueJs虚拟滚动条组件VScroll
<script>
import domUtils from './utils/dom'
export default {
props: {
// 显示原生滚动条
native: Boolean,
// 自动隐藏滚动条
autohide: Boolean,
// 滚动条尺寸
size: { type: [Number, String], default: '' },
// 滚动条颜色
color: String,
// 滚动条层级
zIndex: null
},
data() {
return {
barWidth: 0, // 滚动条宽度
barHeight: 0, // 滚动条高度
ratioX: 1, // 滚动条水平偏移率
ratioY: 1, // 滚动条垂直偏移率
isTaped: false, // 鼠标光标是否按住滚动条
isHover: false, // 鼠标光标是否悬停在滚动区
isShow: !this.autohide, // 是否显示滚动条
}
},
mounted() {
this.$ref__box = this.$refs.ref__box
this.$ref__wrap = this.$refs.ref__wrap
this.$ref__barY = this.$refs.ref__barY
this.$ref__barX = this.$refs.ref__barX
this.$nextTick(this.updated)
},
// ...
methods: {
// 鼠标移入
handleMouseEnter() {
this.isHover = true
this.isShow = true
this.updated()
},
// 鼠标移出
handleMouseLeave() {
this.isHover = false
this.isShow = false
},
// 拖动滚动条
handleDragThumb(e, index) {
let _this = this
this.isTaped = true
let c = {}
domUtils.isIE() ? (e.returnValue = false, e.cancelBubble = true) : (e.stopPropagation(), e.preventDefault())
document.onselectstart = () => false
if(index == 0) {
c.dragY = true
c.clientY = e.clientY
}else {
c.dragX = true
c.clientX = e.clientX
}
domUtils.on(document, 'mousemove', function(evt) {
if(_this.isTaped) {
if(c.dragY) {
_this.$ref__wrap.scrollTop += (evt.clientY - c.clientY) * _this.ratioY
_this.$ref__barY.style.transform = `translateY(${_this.$ref__wrap.scrollTop / _this.ratioY}px)`
c.clientY = evt.clientY
}
if(c.dragX) {
_this.$ref__wrap.scrollLeft += (evt.clientX - c.clientX) * _this.ratioX
_this.$ref__barX.style.transform = `translateX(${_this.$ref__wrap.scrollLeft / _this.ratioX}px)`
c.clientX = evt.clientX
}
}
})
domUtils.on(document, 'mouseup', function() {
_this.isTaped = false
document.onmouseup = null;
document.onselectstart = null
})
},
// 滚动槽
handleClickTrack(e, index) {
console.log(index)
},
// 更新滚动
updated() {
if(this.native) return
// 垂直滚动条
if(this.$ref__wrap.scrollHeight > this.$ref__wrap.offsetHeight) {
this.barHeight = this.$ref__box.offsetHeight **2 / this.$ref__wrap.scrollHeight
this.ratioY = (this.$ref__wrap.scrollHeight - this.$ref__box.offsetHeight) / (this.$ref__box.offsetHeight - this.barHeight)
this.$ref__barY.style.transform = `translateY(${this.$ref__wrap.scrollTop / this.ratioY}px)`
}else {
this.barHeight = 0
this.$ref__barY.style.transform = ''
this.$ref__wrap.style.marginRight = ''
}
// 水平滚动条
...
},
handleResize() {
// 更新滚动条状态
},
// ...
}
}
</script>
vue中directives指令函数监听DOM变化。
// 监听元素/DOM尺寸变化
directives: {
'resize': {
bind: function(el, binding) {
let width = '', height = '';
function get() {
const elStyle = el.currentStyle ? el.currentStyle : document.defaultView.getComputedStyle(el, null);
if (width !== elStyle.width || height !== elStyle.height) {
binding.value({width, height});
}
width = elStyle.width;
height = elStyle.height;
}
el.__vueReize__ = setInterval(get, 16);
},
unbind: function(el) {
clearInterval(el.__vueReize__);
}
}
}
好了,今天就分享到这里。希望大家能喜欢哈!
基于vue.js网页弹窗组件|vue自定义对话框VLayer
链接:https://juejin.cn/post/6901103494971785223/
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
介绍
VScroll滚动条 基于vuejs2.x构建的美化XY轴滚动条组件。支持原生滚动条、鼠标移出是否隐藏滚动条、自定义滚动条尺寸、颜色及层级等功能。拥有漂亮且流畅的滚动体验!
参数配置
props: {
// 是否显示原生滚动条
native: Boolean,
// 是否自动隐藏滚动条
autohide: Boolean,
// 滚动条尺寸
size: { type: [Number, String], default: '' },
// 滚动条颜色
color: String,
// 滚动条层级
zIndex: null
},
快速引入
在main.js中引入组件。
import VScroll from './components/vscroll';
Vue.use(VScroll);
使用组件
<!-- 支持原生滚动条 -->
<v-scroll native>
<img src="https://cn.vuejs.org/images/logo.png" />
<p>这里是自定义内容。这里是自定义内容。这里是自定义内容。</p>
</v-scroll>
<!-- 参数配置 -->
<v-scroll autohide size="15" color="#00a1e0" zIndex="2021">
<img src="https://cn.vuejs.org/images/logo.png" />
<p>这里是自定义内容。这里是自定义内容。这里是自定义内容。</p>
</v-scroll>
实现过程
// vscroll模板
<template>
<div class="vui__scrollbar" ref="ref__box" @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave" v-resize="handleResize">
<div :class="['vscroll__wrap', {native: native}]" ref="ref__wrap" @scroll="handleScroll">
<div class="vscroll__view" v-resize="handleResize"><slot /></div>
</div>
<!-- //水平|垂直滚动条 -->
<div :class="['vscroll__bar vertical', {ishide: !isShow}]" @mousedown="handleClickTrack($event, 0)" :style="{'width': parseInt(size)>=0 ? parseInt(size)+'px' : '', 'z-index': parseInt(zIndex)>=0 ? parseInt(zIndex) : ''}">
<div class="vscroll__thumb" ref="ref__barY" :style="{'background': color, 'height': barHeight+'px'}" @mousedown="handleDragThumb($event, 0)"></div>
</div>
<div :class="['vscroll__bar horizontal', {ishide: !isShow}]" @mousedown="handleClickTrack($event, 1)" :style="{'height': parseInt(size)>=0 ? parseInt(size)+'px' : '', 'z-index': parseInt(zIndex)>=0 ? parseInt(zIndex) : ''}">
<div class="vscroll__thumb" ref="ref__barX" :style="{'background': color, 'width': barWidth+'px'}" @mousedown="handleDragThumb($event, 1)"></div>
</div>
</div>
</template>
/**
* @Desc VueJs虚拟滚动条组件VScroll
<script>
import domUtils from './utils/dom'
export default {
props: {
// 显示原生滚动条
native: Boolean,
// 自动隐藏滚动条
autohide: Boolean,
// 滚动条尺寸
size: { type: [Number, String], default: '' },
// 滚动条颜色
color: String,
// 滚动条层级
zIndex: null
},
data() {
return {
barWidth: 0, // 滚动条宽度
barHeight: 0, // 滚动条高度
ratioX: 1, // 滚动条水平偏移率
ratioY: 1, // 滚动条垂直偏移率
isTaped: false, // 鼠标光标是否按住滚动条
isHover: false, // 鼠标光标是否悬停在滚动区
isShow: !this.autohide, // 是否显示滚动条
}
},
mounted() {
this.$ref__box = this.$refs.ref__box
this.$ref__wrap = this.$refs.ref__wrap
this.$ref__barY = this.$refs.ref__barY
this.$ref__barX = this.$refs.ref__barX
this.$nextTick(this.updated)
},
// ...
methods: {
// 鼠标移入
handleMouseEnter() {
this.isHover = true
this.isShow = true
this.updated()
},
// 鼠标移出
handleMouseLeave() {
this.isHover = false
this.isShow = false
},
// 拖动滚动条
handleDragThumb(e, index) {
let _this = this
this.isTaped = true
let c = {}
domUtils.isIE() ? (e.returnValue = false, e.cancelBubble = true) : (e.stopPropagation(), e.preventDefault())
document.onselectstart = () => false
if(index == 0) {
c.dragY = true
c.clientY = e.clientY
}else {
c.dragX = true
c.clientX = e.clientX
}
domUtils.on(document, 'mousemove', function(evt) {
if(_this.isTaped) {
if(c.dragY) {
_this.$ref__wrap.scrollTop += (evt.clientY - c.clientY) * _this.ratioY
_this.$ref__barY.style.transform = `translateY(${_this.$ref__wrap.scrollTop / _this.ratioY}px)`
c.clientY = evt.clientY
}
if(c.dragX) {
_this.$ref__wrap.scrollLeft += (evt.clientX - c.clientX) * _this.ratioX
_this.$ref__barX.style.transform = `translateX(${_this.$ref__wrap.scrollLeft / _this.ratioX}px)`
c.clientX = evt.clientX
}
}
})
domUtils.on(document, 'mouseup', function() {
_this.isTaped = false
document.onmouseup = null;
document.onselectstart = null
})
},
// 滚动槽
handleClickTrack(e, index) {
console.log(index)
},
// 更新滚动
updated() {
if(this.native) return
// 垂直滚动条
if(this.$ref__wrap.scrollHeight > this.$ref__wrap.offsetHeight) {
this.barHeight = this.$ref__box.offsetHeight **2 / this.$ref__wrap.scrollHeight
this.ratioY = (this.$ref__wrap.scrollHeight - this.$ref__box.offsetHeight) / (this.$ref__box.offsetHeight - this.barHeight)
this.$ref__barY.style.transform = `translateY(${this.$ref__wrap.scrollTop / this.ratioY}px)`
}else {
this.barHeight = 0
this.$ref__barY.style.transform = ''
this.$ref__wrap.style.marginRight = ''
}
// 水平滚动条
...
},
handleResize() {
// 更新滚动条状态
},
// ...
}
}
</script>
vue中directives指令函数监听DOM变化。
// 监听元素/DOM尺寸变化
directives: {
'resize': {
bind: function(el, binding) {
let width = '', height = '';
function get() {
const elStyle = el.currentStyle ? el.currentStyle : document.defaultView.getComputedStyle(el, null);
if (width !== elStyle.width || height !== elStyle.height) {
binding.value({width, height});
}
width = elStyle.width;
height = elStyle.height;
}
el.__vueReize__ = setInterval(get, 16);
},
unbind: function(el) {
clearInterval(el.__vueReize__);
}
}
}
好了,今天就分享到这里。希望大家能喜欢哈!
基于vue.js网页弹窗组件|vue自定义对话框VLayer
链接:https://juejin.cn/post/6901103494971785223/
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

快手点赞APP系统开发
APP作为一种有效的工具,企业级( myxsky366 ,马先生)APP已成为企业在移动终端上的竞争平台。它与网站微博和微信一起构成了新媒体营销的“三驾马车”。越来越多的企业看到企业APP对企业有效开发,市场营销等方面的优势,通过开发,市场营销等带来的优势,认识到企业移动app的市场营销价值以及抓住用户移动终端桌面的重要性,并希望利用APP实现与用户零距离绑定。对于企业而言,选择开发自己的或将自己的企业APP外包是没有时间延迟的。
APP作为一种有效的工具,企业级( myxsky366 ,马先生)APP已成为企业在移动终端上的竞争平台。它与网站微博和微信一起构成了新媒体营销的“三驾马车”。越来越多的企业看到企业APP对企业有效开发,市场营销等方面的优势,通过开发,市场营销等带来的优势,认识到企业移动app的市场营销价值以及抓住用户移动终端桌面的重要性,并希望利用APP实现与用户零距离绑定。对于企业而言,选择开发自己的或将自己的企业APP外包是没有时间延迟的。
收起阅读 »
六度空间系统开发源码
六度空间系统开发源码咨询王经理l83薇35lO電4692,六度空间源码开发介绍,六度空间APP开发
六度空间系统介绍
六度分割虽然是个社会学的理论,但是实际上它更像一个数学理论,很多人说它和四色问题有异曲同工之妙。在我看来,六度分割很好的阐述了一个网状的结构(我们的人类社会),增强了不同节点之间的联系和连接关系,然而它并不完整,也并不足以指导我们的实践。但这个理论在很大程度上让人们对于信息时代的人类社会有了很深的理解与探索。
六度空间系统开发源码咨询王经理l83薇35lO電4692,六度空间源码开发介绍,六度空间APP开发
六度空间系统介绍
六度分割虽然是个社会学的理论,但是实际上它更像一个数学理论,很多人说它和四色问题有异曲同工之妙。在我看来,六度分割很好的阐述了一个网状的结构(我们的人类社会),增强了不同节点之间的联系和连接关系,然而它并不完整,也并不足以指导我们的实践。但这个理论在很大程度上让人们对于信息时代的人类社会有了很深的理解与探索。