当前位置: 首页 > news >正文

北京网站建设哪家好seo代码优化包括哪些

北京网站建设哪家好,seo代码优化包括哪些,顺德公司做网站,自己的公网ip可以做网站需求&#xff1a;上面有几个按钮&#xff0c;其中有一个切换是图片 用v-if会导致图片加载慢 实现方法&#xff1a; 一进来就加载&#xff0c;通过监听元素显示&#xff0c;用于控制canvas的宽高&#xff0c;从而达到隐藏的效果 组件dowolad.vue <template><view …

需求:上面有几个按钮,其中有一个切换是图片

用v-if会导致图片加载慢

实现方法:

一进来就加载,通过监听元素显示,用于控制canvas的宽高,从而达到隐藏的效果

组件dowolad.vue

<template><view style="margin-top: 20rpx;"><canvas canvas-id="myCanvas" :style="scaleObj"></canvas><button :loading="loading" :disabled="loading" @click="saveImg" class="confirmBnt" v-if="!weixin && show">保存二维码</button></view></template><script>export default {props: ['show'],data() {return {show: true,canvasId: 'myCanvas',imagePath: '',canvaseAttr:{width: 0,height: 0,},scaleObj:{},loading: false,weixin: false};},mounted(){this.weixin = this.$wechat.isWeixin();this.init();},watch:{show:{handler(newData, oldData){let scale = {width: 0,height: 0,}if(newData){scale.width = this.canvaseAttr.width+'px';scale.height = this.canvaseAttr.height+'px';}this.scaleObj = scale;},deep: true,immediate: true}},methods: {init(){this.getImageInfo();},getImageInfo() {let that = this;uni.getSystemInfo({success: (window) => {const screenWidth = window.windowWidth;uni.getImageInfo({src: 'https://media.sammu.top/pay_bank_img.png',success: (res) => {let scale = screenWidth/res.width;let height = res.height*scale;that.canvaseAttr = {width: screenWidth,height: height,}that.imagePath = res.path;that.drawCanvas();},fail: (err) => {console.log(err);}});},});},drawCanvas() {this.$nextTick(()=>{const ctx = uni.createCanvasContext('myCanvas', this);ctx.drawImage(this.imagePath, 0, 0, this.canvaseAttr.width, this.canvaseAttr.height);ctx.draw();})},saveImg(){const ctx = uni.createCanvasContext(this.canvasId, this);let that = this;that.loading = true;// 绘制完成  ctx.draw(true, function () {uni.canvasToTempFilePath({canvasId: that.canvasId,success: (res) => {// #ifdef H5that.saveH5Canvas(res)// #endif// #ifdef APPuni.saveImageToPhotosAlbum({filePath: res.tempFilePath,success: () => {uni.showToast({title: '保存成功',icon: 'none'})that.loading = false;uni.hideLoading();},fail: () => {uni.showToast({title: '保存失败',icon: 'none'})that.loading = false;uni.hideLoading();}});// #endif},fail: (err) => {that.loading = false;console.log(err, "错误信息");}});})},saveH5Canvas(res) {let that = this;try {// 在 h5 中,res.tempFilePath 返回的是 base64 类型要处理,通过 a 标签的形式下载var arr = res.tempFilePath.split(',');var bytes = atob(arr[1]);let ab = new ArrayBuffer(bytes.length);let ia = new Uint8Array(ab);for (let i = 0; i < bytes.length; i++) {ia[i] = bytes.charCodeAt(i);}var blob = new Blob([ab], {type: 'application/octet-stream'});var url = URL.createObjectURL(blob);var a = document.createElement('a');a.href = url;a.download = new Date().valueOf() + ".png";var e = document.createEvent('MouseEvents');e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);a.dispatchEvent(e);URL.revokeObjectURL(url);uni.showToast({title: '保存成功',icon: 'none'})that.loading = false;uni.hideLoading();} catch (e) {uni.showToast({title: '保存失败',icon: 'none'})that.loading = false;uni.hideLoading();}    },},}</script><style lang="scss" scoped>.confirmBnt{position: fixed;bottom: 20rpx;width: calc(100% - 20rpx);left: 50%;transform: translateX(-50%);background: var(--view-theme);border-radius: 24rpx;height: 108rpx;line-height: 108rpx;font-size: 40rpx;font-weight: 700;text-align: center;color: #fff;}</style>

调用

<dowload ref="dowloadRef" :show="active == 1"></dowload>

http://www.wangmingla.cn/news/155177.html

相关文章:

  • 微云影视自助建站系统朋友圈推广文案
  • 做啥网站能挣钱国内企业网站模板
  • 百度站长app关键词seo资源
  • 网站模板怎样发布海洋seo
  • 小伙反串做直播视频网站百度影音在线电影
  • 北海哪里做网站建设百度引流推广怎么收费
  • 网站的基础建设怎样制作一个网页
  • 精准网站seo诊断报告北京seo公司工作
  • 如何对网站的图片做cdn武汉刚刚突然宣布
  • 单品电商网站建设人工智能培训班收费标准
  • 沈阳做网站的设计公司东莞互联网推广
  • 网站后期增加内容市场营销产品推广策划方案
  • 郑州哪里做网站汉狮十大免费网站推广入口
  • 小学学校网站模板免费下载市场推广专员
  • 常熟祥云平台网站建设南昌seo顾问
  • 全球跨境电商平台百度刷排名优化软件
  • 郴州网站制作公司招聘百度seo软件曝光行者seo
  • 做网站怎么套用模板百度账号登陆入口
  • 新增备案网站百度旗下13个app
  • 视频聚合网站怎么做不侵权免费网站推广网址
  • excel网站链接怎么做批量广州王牌seo
  • 网站建设价目b2c有哪些电商平台
  • 如何在网上接做网站的小项目crm软件
  • 做百度推广首先要做网站吗个人怎么做推广
  • 多品牌网站建设神马seo教程
  • 网站开发预算报表百度账号怎么改名字
  • designer怎么做网站怎么做一个网站页面
  • 个人网站源代码html广告推广方式有哪几种
  • 网站制作 苏州蜜雪冰城网络营销案例分析
  • 免费学服装设计的网站有免费推广平台