nuxt.renderAndGetWindow(url, options)
Nuxt アプリケーションの与えられた URL から window
を取得します。
-
型:
Function
-
引数:
String
-
String
: レンダリングする URL -
オプション
Object
: オプション
-
virtualConsole:
Boolean
(デフォル:true
)
-
-
戻り値:
Promise
-
戻り値:
window
-
戻り値:
このメソッドはテスト目的で作られました。
この関数を使うためには jsdom
をインストールする必要があります:
npm install --save-dev jsdom
例:
const { loadNuxt } = require('nuxt')
async function init() {
// すでにプロジェクトをビルド済みと仮定します
const nuxt = await loadNuxt({ for: 'start' })
await nuxt.listen(3000)
const window = await nuxt.renderAndGetWindow('http://localhost:3000')
// head `<title>` を表示する
console.log(window.document.title)
nuxt.close()
}
init()
この次は?
コンポーネント用語集 をチェックしてみましょう。
このページをGitHubで編集する
更新日 Sun, Mar 12, 2023
Olga Bulat
Maciek Palmowski
Sébastien Chopin
Daniel Roe
Clément Ollivier
Paiva
Florian Reuschel
Rishi Raj Jain
Savas Vedova
Steven Soekha
Vinícius Alves
Kareem Dabbeet
Valentín Costa
Ryan Skinner
Alex Hirzel
Ajeet Chaulagain
René Eschke
Nico Devs
Muhammad
Nazaré da Piedade
Naoki Hamada
Tom
Yann Aufray
Anthony Chu
Nuzhat Minhaz
Lucas Portet
Richard Schloss
bpy
Antony Konstantinidis
Hibariya
Jose Seabra
Eze
Florian LEFEBVRE
Lucas Recoaro
Julien SEIXAS
Hugo
Sylvain Marroufin
Spencer Cooley
Piotr Zatorski
Vladimir Semenov
Harry Allen
kazuya kawaguchi
Unai Mengual
Hyunseung Lee
Alexandre Chopin
pooya parsa
Nick Medrano
Mosaab Emam
Ilja
Heitor Ramon Ribeiro
Nero
Yoon Han
Ikko Eltociear Ashimine
FamCodings