Page traduite Le contenu de cette page peut être déprécié.
nuxt.renderAndGetWindow(url, options)
Récupère la window d'une URL donnée de l'application Nuxt.
-
Type :
Function -
Argument :
String-
String: URL à afficher -
Optional,
Object: options
-
virtualConsole:
Boolean(par défaut :true)
-
-
Renvois :
Promise-
Renvois :
window
-
Renvois :
Cette méthode est faite à des fins de test.
Pour utiliser cette fonction, vous devez installer jsdom :
npm install --save-dev jsdom
Exemple :
const { loadNuxt } = require('nuxt')
async function init() {
// En supposant que vous ayez déjà construit votre projet
const nuxt = await loadNuxt({ for: 'start' })
await nuxt.listen(3000)
const window = await nuxt.renderAndGetWindow('http://localhost:3000')
// Afficher le `<titre>`
console.log(window.document.title)
nuxt.close()
}
init()
Prochaine étape
Consultez le Glossaire des composants
Editer cette page sur GitHub
Mise à jour le mar. 5 avril 2022
Nazaré da Piedade
Mosaab Emam
Sylvain Marroufin
Iljs Путлер Капут
Daniel Roe
Heitor Ramon Ribeiro
Nero
Sébastien Chopin
Clément Ollivier
Yoon Han
Ikko Ashimine
FamCodings
Ayouli
F. Hinkelmann
felipesuri
Christophe Carvalho Vilas-Boas
Leoš Literák
Trizotti
Marcello Bachechi
Rodolphe
Thomas Underwood
Shek Evgeniy
Lukasz Formela
Hugo Torzuoli
Kareem Dabbeet
tramplay
verebelyicsaba
Adam
Nate Butler
Sandra Rodgers
Arpit Patidar
Matthew Kuehn
Steven DUBOIS
Travis Lindsey
syagawa
Maxime
かる
Al Power
Florent Delerue
quanghm
José Manuel Casani Guerra
Unai Mengual
kazuya kawaguchi
Michael Lynch
Tomachi
pooya parsa
Meir Roth