Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在VUE js中为live网站编写自动调用函数?_Javascript_Vuejs2_Google Cloud Firestore - Fatal编程技术网

Javascript 如何在VUE js中为live网站编写自动调用函数?

Javascript 如何在VUE js中为live网站编写自动调用函数?,javascript,vuejs2,google-cloud-firestore,Javascript,Vuejs2,Google Cloud Firestore,我试图在Vue js中编写一个函数,它可以在特定的时间间隔自动调用live网站,其工作原理是检查数据库(google firebase cloud firestore)集合/对象。 此功能不依赖于任何事件,如(单击、更改、加载等)。 它是完全独立的,只是在特定的时间间隔调用它您可以在main.js中的Vue对象中设置计时器 new Vue({ el: '#app', data: {}, created: function() { setInterval((

我试图在Vue js中编写一个函数,它可以在特定的时间间隔自动调用live网站,其工作原理是检查数据库(google firebase cloud firestore)集合/对象。 此功能不依赖于任何事件,如(单击、更改、加载等)。
它是完全独立的,只是在特定的时间间隔调用它

您可以在
main.js中的Vue对象中设置计时器

new Vue({
    el: '#app',
    data: {},
    created: function() {
        setInterval(() => {
          // call your API to check the database stuff
        }, 1000)
    }
});

但更好的方法是在后端创建一个动态调度的后台作业

听起来是一个相当清晰的用例。您在实施时遇到了什么问题?您能否编辑问题以显示您已经尝试了什么,以及您在哪里遇到了问题?请尝试服务器中的cron作业