반응형

 

  methods: {
        btcTrkAPICall: function () {
            axios    
                .get('https://www.api1.com/api/ticker')    
                .then(response => (this.btctrk = response.data))    
                .catch(error => console.log(error))    
        },
        bnncAPICall: function () {
            axios    
                .get('https://api.api2.com/api/v3/ticker/bookTicker')    
                .then(response => (this.bnnc = response.data))    
                .catch(error => console.log(error))    
        },
        intervalFetchData: function () {
            setInterval(() => {    
                this.btcTrkAPICall();
                this.bnncAPICall();
                }, 1000);    
        }
    },
    mounted () {
        // Run the functions once when mounted 
        this.btcTrkAPICall();
        this.bnncAPICall();
        // Run the intervalFetchData function once to set the interval time for later refresh
        this.intervalFetchData();
    }

https://stackoverflow.com/questions/54601694/how-to-auto-refresh-a-computed-property-at-axios-in-vuejs

반응형
반응형

얍얍

<html>
    <head></head>
    
    <body>
        <div>
            <span id="num">5</span></div>
    </body>
    
    <script>
        // 1초 마다  1씩 차감
        let time = 5;
        var 타이머 = setInterval(얍,1000);

        function 얍(){

            if ( time >= 1 ) {
                time = time-1;
                document.querySelector('#num').innerHTML = time;
            }else{
                clearTimeout(타이머);
                // 이걸 안하면 타이머 계속 호출한다..흐음 ..
            }
            // 계속 호출 되는거 확인용 콘솔
            // console.log('ttttt') 
        }
    </script>
    
</html>

이거 왜 할때마다 헷갈리지 ㅎㅎ

 

 

반응형

+ Recent posts