Translated page Contents of this page might be outdated.
nuxt.renderAndGetWindow(url, options)
Recebe o window
a partir de uma dada URL de uma aplicação Nuxt.
-
Tipo:
Function
-
Argumento:
String
-
String
: URL para renderizar -
Object
, Opcional: opções
-
virtualConsole:
Boolean
(valor padrão:true
)
-
-
Retorna:
Promise
-
Retorna:
window
-
Retorna:
Este método foi feito para fins de teste.
Para usar esta função, você precisa instalar o jsdom
:
npm install --save-dev jsdom
Exemplo:
const { loadNuxt } = require('nuxt')
async function init() {
// Assumindo que você já tem construido o seu projeto
const nuxt = await loadNuxt({ for: 'start' })
await nuxt.listen(3000)
const window = await nuxt.renderAndGetWindow('http://localhost:3000')
// Exibe o cabeçalho `<title>`
console.log(window.document.title)
nuxt.close()
}
init()
O que se segue
Consulte o livro Glossário de Componentes
Edit this page on GitHub
Updated at Mon, Aug 19, 2024












































