nuxt.renderAndGetWindow

2020-02-13 17:50 更新

nuxt.renderAndGetWindow(url, options = {})

  • 類型: Function
  • 參數(shù): StringString: 待渲染的 URL 路徑可選, Object: optionsvirtualConsole: Boolean (默認(rèn)值:true)
  • 返回值: PromisePromise 最終返回的值: window
渲染指定url并獲取對應(yīng)的window對象。

這個方法只用于 測試目的

要使用這個方法,需要先安裝 jsdom:

npm install --save-dev jsdom

例如:

const Nuxt = require('nuxt')
const nuxt = new Nuxt()

nuxt.renderAndGetWindow('http://localhost:3000')
  .then((window) => {
  // 顯示文檔標(biāo)題
    console.log(window.document.title)
  })


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號