nuxt.renderAndGetWindow(url, options = {})

  • 型: Function
  • 引数: String
    1. String: レンダリングする URL
    2. オプション, Object: オプション
      • virtualConsole: Boolean(デフォルト: true
  • 戻り値: Promise
    • 戻り値: window

Nuxt.js アプリケーションの URL を渡して window を取得します。

このメソッドは テストする目的 で使われます。

この関数を使うためには jsdom をインストールする必要があります。:

npm install --save-dev jsdom

例:

const { Nuxt, Builder } = require('nuxt')

const config = require('./nuxt.config.js')
config.dev = false

const nuxt = new Nuxt(config)

nuxt.renderAndGetWindow('http://localhost:3000')
.then((window) => {
  // head 内の <title> の内容を表示
  console.log(window.document.title)
})

間違いを見つけた、またはドキュメントに貢献したいですか? GitHub でこのページを編集する