index.uvue 2.6 KB
Newer Older
杜庆泉's avatar
杜庆泉 已提交
1 2 3 4 5 6 7 8 9 10
<template>
    <div>
        <button @tap="changeUrl">播放本地动画资源</button>
		<button @tap="changeServerUrl">播放远程动画资源</button>
		
        <button @tap="changeAutoPlay">测试AutoPlay</button>
        <button @tap="changeLoop">测试Loop</button>
        <button @tap="changeAction(1)">测试action play</button>
        <button @tap="changeAction(2)">测试action pause</button>
        <button @tap="changeAction(3)">测试action stop</button>
Y
yurj26 已提交
11
       <!-- <uts-animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action"
杜庆泉's avatar
杜庆泉 已提交
12 13
            :hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest"
            :style="{width:widthNum+'rpx',height:heightNum+'px',background:yanse}">
Y
yurj26 已提交
14
        </uts-animation-view> -->
杜庆泉's avatar
杜庆泉 已提交
15 16 17 18
        
    </div>
</template>

Y
yurj26 已提交
19
<script lang="ts">
杜庆泉's avatar
杜庆泉 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
  
    export default {
        data() {
            return {
                hidden: false,
                autoplay: false,
                action: "play",
                loop: false,
                yanse: "red",
                widthNum: 750,
                heightNum: 200,
                comShow: true,
                animUrl: "/static/anim_a.json"
            }
        },
        
        methods: {

            changeAutoPlay: function() {
                this.autoplay = !this.autoplay
            },
            changeUrl: function() {
                if (this.animUrl == "/static/anim_a.json") {
                    this.animUrl = "/static/anim_b.json"
                } else {
                    this.animUrl = "/static/anim_a.json"
                }
            },

			changeServerUrl: function() {
                this.animUrl = "https://b.bdstatic.com/miniapp/images/lottie_example_one.json"
            },
Y
yurj26 已提交
52
            changeAction: function(type: number) {
杜庆泉's avatar
杜庆泉 已提交
53 54 55 56 57 58 59 60 61 62 63
                if (type == 1) {
                    this.action = "play"
                } else if (type == 2) {
                    this.action = "pause"
                } else if (type == 3) {
                    this.action = "stop"
                }
            },
            changeLoop: function() {
                this.loop = !this.loop
            },
Y
yurj26 已提交
64
            testAnimEnd: function() {
杜庆泉's avatar
杜庆泉 已提交
65 66 67
                console.log("testAnimEnd");
            },

Y
yurj26 已提交
68 69
            changeRepeat: function() {
                // this.$refs["animView"].updateRepeatConfig("RESTART");
杜庆泉's avatar
杜庆泉 已提交
70
            },
Y
yurj26 已提交
71
            lottieClickTest: function() {
杜庆泉's avatar
杜庆泉 已提交
72 73
                console.log("lottieClickTest");
            },
Y
yurj26 已提交
74
            lottieLongpressTest: function() {
杜庆泉's avatar
杜庆泉 已提交
75 76 77 78 79
                console.log("lottieClickTest");
            },
        }
    }
</script>