繁体   English   中英

如何解决 Marquee 绊倒问题?

[英]How can I solve the Marquee stumble problem?

我正在使用 Laravel + Vue.js。 我通过 API 拍摄公告。 但是当我用手书写时,选框工作正常。 它在一个连续的循环中滑动。 但是当我想打印 vue.js 附带的值时,文本到达末尾时不会移动。 绞刑。 颤抖。

$('.marquee').marquee({
    //speed in milliseconds of the marquee
    duration: 8000,
    //gap in pixels between the tickers
    gap: 0,
    //time in milliseconds before the marquee will start animating
    delayBeforeStart: 0,
    //'left' or 'right'
    direction: 'left',
    //true or false - should the marquee be duplicated to show an effect of continues flow
    duplicated: true
});

Vue.js 代码

export default {
    data() {
        return {
            announcements: ""
        }
    },

    created() {
        this.getAnnouncements();
    },

    methods: {
        getAnnouncements() {
            axios.get('/get-announcements')
                .then((response) => {
                    this.announcements = response.data;
                })
                .catch(function (error) {
                    console.log(error);
                })
        }
    },

    mounted() {
        setInterval(() => {
            this.getAnnouncements();
        }, 10000);
    },

    watch: {
        announcements(val) {
            this.announcements = val
        }
    }
}

在职的;

在此处输入图片说明

<div id="tv-announcement" class="marquee">
    Lorem ipsum test.Lorem ipsum test.Lorem ipsum test.Lorem ipsum test. 
</div>

不工作;

在此处输入图片说明

<div id="tv-announcement" class="marquee">
    {{ announcements }}
</div>

为什么会这样? 这很荒谬。

从 AJAX 请求中获取数据后初始化选取框。 而且你不需要看announcements因为它已经是一个反应性的属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM