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

如何做外贸网站qq群怎么优化排名靠前

如何做外贸网站,qq群怎么优化排名靠前,怎样查看网站是用什么cms_做的,做自媒体好还是网站好把一个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.hkea.cn/news/93669/

相关文章:

  • 建设银行深分行圳招聘网站做游戏推广一个月能拿多少钱
  • 北京网站建设及推广招聘关键词排名代做
  • 对网站建设的意见建议网络营销推广的方法有哪些
  • 爬虫网站怎么做怎样才能在百度上面做广告宣传
  • 网站页码南昌做seo的公司有哪些
  • 网络设计方案包括哪些深圳百度推广seo公司
  • 亚马逊跨境电商开店站长工具seo综合查询5g
  • 网站怎么做百度快照logo百度快照优化推广
  • 山西网站建设排名seo技术培训山东
  • 日韩系成人影片成首选网站如何优化推广
  • 网站到期续费通知搜索风云排行榜
  • 网站公司说我们做的网站服务器不够用哪个杭州seo好
  • 类似淘宝网站建设费用杭州哪家seo公司好
  • 装修网站怎样做seo专员很难吗
  • 无锡网站外包如何接广告赚钱
  • 英文网站制作 官网淘宝标题优化网站
  • 电力建设网站网络推广网站的方法
  • 如何做网站窗口网站优化网络推广seo
  • 营销型网站建设效果网络营销策划推广方案
  • 专业的网站搭建多少钱网站seo优化价格
  • 广州公司网站设计制作win10优化大师官网
  • 做调查哪个网站比较可靠百度指数查询
  • 怎么在建设厅网站报名广州网站优化服务
  • 怎么用dw做静态网站b站好看的纪录片免费
  • 济南网站建设那家好网站制作公司有哪些
  • 域名和网站名不一样营销公司
  • discuz做电影网站免费网站seo
  • 惠民建设局网站明年2024年有疫情吗
  • 卫龙的网站是谁做的今日的新闻
  • 厚街找人做网站动态网站设计