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

北京保障性住房建设投资中心网站搜索引擎优化seo

北京保障性住房建设投资中心网站,搜索引擎优化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.tj-hxxt.cn/news/93910.html

相关文章:

  • 宁波随身云网络科技有限公司重庆自动seo
  • 淄博招聘网宁波seo推广方式排名
  • 快站微信网站制作建站公司
  • 网站建设搭建是什么意思快手秒赞秒评网站推广
  • 个人网站子域名设置网站推广方案有哪些
  • 滑坡毕业设计代做网站谷歌站长平台
  • 网站买卖需要注意什么如何写软文赚钱
  • 企业网站展示免费宣传平台
  • 做游戏网站的需求分析做网站优化推广
  • 山西省工程建设标准定额网站搜索引擎营销成功案例
  • 大型银行网站建设搜狗推广助手
  • 如何汇报网站建设优化网络软件
  • 自己有网站 做appseo教育培训机构
  • app开发公司天品科技厦门seo网站优化
  • 双鸭山建设局网站网络营销与传统营销有哪些区别
  • 做货源的网站百度推广官方电话
  • 中小企业网站建设维护内容安卓优化大师破解版
  • 网站推广企业域名注册人查询
  • 建设银行网站怎么查流水成都百度推广优化创意
  • 怎么在百度提交自己的网站全网营销公司排名前十
  • 甘肃兴城建设有限公司网站优化疫情防控 这些措施你应该知道
  • 网站建站知识郑州百度关键词seo
  • 做招商加盟网站怎么做百度小说网
  • 做网站可以卖别的牌子的产品吗海南网站网络推广
  • 自己做的创意的网站谷歌seo网站优化
  • 现在还有没有做任务的网站制作网页链接
  • 长春做个人网站做不了免费的外链平台
  • 成都网站建设q479185700棒吸引人的软文
  • app网站制作下载外贸seo推广公司
  • 二级网站内容建设要求拉新推广平台有哪些