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で編集する
更新日 Mon, Aug 19, 2024












































