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

辅助购卡网站怎么做出于安全保障需要

辅助购卡网站怎么做,出于安全保障需要,seo知识总结,网线制作实验原理把一个json的动图展示在页面上。使用的是插件lottie-miniprogramhttps://blog.csdn.net/qq_33769914/article/details/128705922之前介绍过。但是发现使用在taro使用的时候他会报错。那可能是因为我们 wx.createSelectorQuery().select(#canvas).node(res > {console.log(re…

把一个json的动图展示在页面上。使用的是插件lottie-miniprogramhttps://blog.csdn.net/qq_33769914/article/details/128705922之前介绍过。但是发现使用在taro使用的时候他会报错。

那可能是因为我们

wx.createSelectorQuery().select('#canvas').node(res => {

   console.log(res)//打印这个的时候是null。所以下面的res.node就会报错

const canvas = res.node

const context = canvas.getContext('2d')

})

我们可以应该把获取的生命周期改成useDidShow。然后再加个延迟。

useDidShow(()=>{

setTimeout(()=>{

init()

}, 0)

})

const init = ()=> {

if (inited.value) {

return

}

Taro.createSelectorQuery().select(`#lottie`).node(res => {

console.log("res",res)

const canvas = res.node

if(canvas){

const context = canvas.getContext('2d')

if (pixelRatio.value) {

context.scale(pixelRatio.value, pixelRatio.value)

canvas.width = 300* pixelRatio.value

canvas.height = 300* pixelRatio.value

}

Lottie.setup(canvas)

lottieObj = Lottie.loadAnimation({

loop: props.loop,

autoplay: props.autoplay,

animationData: props.jsonData,

rendererSettings: {

context,

},

})

inited.value = true

// emits('onComplete')

}

}).exec()

}

全部代码如下。把它方做一个组件使用lottieView.vue

<template>

<canvas class="canvas" :id="`lottie`" type="2d" />

</template>

<script lang="ts" setup>

import { onMounted, defineProps, ref } from 'vue'

import Taro from "@tarojs/taro";

import Lottie from 'lottie-miniprogram'

import lottieJson from './data.json'    //json的动画可以找产品要

const props = defineProps({

id: {

type: String,

default: ''

},

jsonData: {

type: Object,

default: lottieJson

},

autoplay: {

type: Boolean,

default: false

},

loop: {

type: Boolean,

defalut: false

},

assetsPath: {

type: String,

defalut: ''

}

})

const emits = defineEmits(['onComplete'])

const sysinfo = Taro.getSystemInfoSync(); //获取设备系统的数据

const pixelRatio = ref(sysinfo.pixelRatio)

let lottieObj: any = undefined

Taro.useDidShow(()=>{

console.log('lottie---useReady');

setTimeout(()=>{

init(1)

}, 0)

})

// onMounted(()=>{

// console.log('lottie---onMounted');

// setTimeout(()=>{

// init(3)

// }, 10)

// })

const inited = ref(false)

// 初始化加载动画

const init = (type)=> {

console.log("type",type)

if (inited.value) {

return

}

Taro.createSelectorQuery().select(`#lottie`).node(res => {

console.log("res",res)

const canvas = res.node

if(canvas){

const context = canvas.getContext('2d')

if (pixelRatio.value) {

context.scale(pixelRatio.value, pixelRatio.value)

canvas.width = 300* pixelRatio.value

canvas.height = 300* pixelRatio.value

}

Lottie.setup(canvas)

lottieObj = Lottie.loadAnimation({

loop: props.loop,

autoplay: props.autoplay,

animationData: props.jsonData,

rendererSettings: {

context,

},

})

inited.value = true

// emits('onComplete')

}

}).exec()

}

const play = () => {

lottieObj && lottieObj.play()

}

const stop = () => {

lottieObj && lottieObj.stop()

}

const pause = () => {

lottieObj && lottieObj.pause()

}

defineExpose({

play,

stop,

pause

})

</script>

<style lang="less"></style>

使用import LottieView from '@/magic-head/pages/components/lottieView'

<LottieView

class="lottie"

:autoplay="true"

:loop="true"

/>

http://www.yayakq.cn/news/781140/

相关文章:

  • 昆山网站建设公司苏州爬虫科技百度搜索排名怎么做
  • 企业网站建设方案详细方案建设局怎么进
  • 论坛网站模板ui培训中心
  • 还有哪些网站可以做淘宝活动千万不能 网站
  • php搭建网站教程网站升级改造建设方案
  • 关于旅游网站开发的研究方法多少钱 英文
  • 阆中网站网站建设网站开发要服务器吗
  • 公司建网站制作平台睢阳区网
  • .net 手机网站开发企业展厅数字多媒体
  • 人跟狗做网站济南公司建设网站
  • 官方网站建立厦门今天刚刚发生的新闻
  • 江苏中南建设集团网站是多少前端和后端哪个常熬夜
  • 淘客如何做网站推广工业设计展板
  • uehtml 网站源码网站开发界面图标设计
  • 江苏和住房建设厅网站做外贸网站特色
  • 深圳网站营销推广公司电话网络营销方式有哪些?举例说明
  • 手机网站建设价格网站建设默认字体
  • 网站建设实训报告建议如何对一个网站进行seo
  • 麦壳云网站建设个人社保网上服务平台
  • 无锡网站排名公司seo优化网站的注意事项
  • 烟台网站建设 制作 推广谷歌seo快速排名优化方法
  • 烟台市做网站的价格火鸟门户系统
  • 数据来源网站怎么做脚注电子商务营销手段有哪些
  • 高仿卡西欧手表网站诸城哪有做公司网站的
  • 联科三网合一网站建设系统wordpress 主题开心版
  • 四川省建设厅注册管理中心网站建站智能模板
  • 百度站长工具平台登录云南网站备案难吗
  • 江西城乡建设部网站首页哪个网站开发培训好
  • 广州商城建站产品摄影网站
  • 海外购物网站建设哪个网站可以做笔译兼职