Hice un botón para usar una API para reiniciar una aplicación
Ese botón funciona bien. Sin embargo, cuando se trata de alertas emergentes, el botón Aceptar a veces no funciona. Incluso si hago clic y vuelvo a hacer clic, no cierra la ventana emergente de alerta. Si vuelvo a hacer clic después de esperar un momento como tres segundos, entonces cierra la ventana emergente de alerta normalmente. No sé cuál será el problema real, porque no experimenté esto antes. ¿Puede ser un problema del navegador (chrome)? ¿O vue framework o nuxt framework? Uso el marco nuxt en este código.
El código está debajo
reiniciarApp.vue
<template> <button>restart</button> </template> <script> import { createRestart } from '@/api/agent' export default { methods:{ restart() { if (confirm('Restart agent?')) { createRestart().then((res) => { if (res.status == 200) { alert('Agent is restarted') }else{ alert("Agent isn't restarted") } }).catch((err)=>{ alert('Agent has a error to restart >>', err) }) } }, } } </script>@/api/agente.js
import axios from "axios"; import { headers } from "../config/env"; export function createRestart() { return axios.post("/api/agent/schedule/restart", {}, { headers }); }/api.js
//(...) router.post('/agent/schedule/restart', async (req, res) => { const axiosInstance = axios.create({ timeout:3000 }); try { const result = await axiosInstance.post( "http://agentUrl" + '/v1/restart', {}, config ) res.json(result.data) } catch (err) { console.log(err) res.sendStatus(500) } }) //(...)