nuxtJs context 对象的具体结构图

{
  isStatic: false,
  isDev: true,
  isHMR: false,
  app: <ref *1> {
    head: {
      title: 'nuxt-app',
      meta: [Array],
      link: [Array],
      style: [],
      script: [],
      htmlAttrs: [Object]
    },
    store: Store {
      _committing: false,
      _actions: [Object: null prototype] {},
      _actionSubscribers: [],
      _mutations: [Object: null prototype],
      _wrappedGetters: [Object: null prototype] {},
      _modules: [ModuleCollection],
      _modulesNamespaceMap: [Object: null prototype],
      _subscribers: [],
      _watcherVM: [Vue],
      _makeLocalGettersCache: [Object: null prototype] {},
      dispatch: [Function: boundDispatch],
      commit: [Function: boundCommit],
      strict: true,
      getters: {},
      _vm: [Vue],
      '$router': [VueRouter],
      registerModule: [Function: registerModule],
      app: [Circular *1],
      '$config': [Object],
      '$cookies': [Object],
      '$icon': [Function: getIcon],
      '$axios': [Function]
    },
    router: VueRouter {
      app: [Vue],
      apps: [Array],
      options: [Object],
      beforeHooks: [],
      resolveHooks: [],
      afterHooks: [],
      matcher: [Object],
      fallback: false,
      mode: 'abstract',
      history: [AbstractHistory],
      push: [Function: push],
      resolve: [Function (anonymous)]
    },
    nuxt: {
      defaultTransition: [Object],
      transitions: [Array],
      setTransitions: [Function: setTransitions],
      err: null,
      dateErr: null,
      error: [Function: error]
    },
    render: [Function: render],
    data: [Function: data],
    beforeCreate: [Function: beforeCreate],
    created: [Function: created],
    mounted: [AsyncFunction: mounted],
    watch: { 'nuxt.err': 'errorChanged' },
    computed: {
      isOffline: [Function: isOffline],
      isFetching: [Function: isFetching]
    },
    methods: {
      refreshOnlineStatus: [Function: refreshOnlineStatus],
      refresh: [AsyncFunction: refresh],
      errorChanged: [Function: errorChanged],
      setLayout: [Function: setLayout],
      loadLayout: [Function: loadLayout]
    },
    components: { NuxtLoading: [Object] },
    context: [Circular *2],
    '$config': { baseURL: '/api', _app: [Object] },
    '$cookies': {
      parseJSON: true,
      set: [Function: set],
      setAll: [Function: setAll],
      get: [Function: get],
      getAll: [Function: getAll],
      remove: [Function: remove],
      removeAll: [Function: removeAll],
      nodeCookie: [Object]
    },
    '$icon': [Function: getIcon],
    '$axios': [Function: wrap] {
      request: [Function: wrap],
      getUri: [Function: wrap],
      delete: [Function: wrap],
      get: [Function: wrap],
      head: [Function: wrap],
      options: [Function: wrap],
      post: [Function: wrap],
      put: [Function: wrap],
      patch: [Function: wrap],
      defaults: [Object],
      interceptors: [Object],
      CancelToken: [Function],
      isCancel: [Function: isCancel],
      setBaseURL: [Function: bound setBaseURL],
      setHeader: [Function: bound setHeader],
      setToken: [Function: bound setToken],
      onRequest: [Function: bound onRequest],
      onResponse: [Function: bound onResponse],
      onRequestError: [Function: bound onRequestError],
      onResponseError: [Function: bound onResponseError],
      onError: [Function: bound onError],
      create: [Function: bound create],
      '$request': [Function: bound ],
      '$delete': [Function: bound ],
      '$get': [Function: bound ],
      '$head': [Function: bound ],
      '$options': [Function: bound ],
      '$post': [Function: bound ],
      '$put': [Function: bound ],
      '$patch': [Function: bound ]
    }
  },
  store: <ref *5> Store {
    _committing: false,
    _actions: [Object: null prototype] {},
    _actionSubscribers: [],
    _mutations: [Object: null prototype] {
      increment: [Array],
      setUser: [Array],
      'todos/add': [Array],
      'todos/remove': [Array]
    },
    _wrappedGetters: [Object: null prototype] {},
    _modules: ModuleCollection { root: [Module] },
    _modulesNamespaceMap: [Object: null prototype] { 'todos/': [Module] },
    _subscribers: [],
    _watcherVM: <ref *3> Vue {
      _uid: 11,
      _isVue: true,
      '$options': [Object],
      _renderProxy: [Circular *3],
      _self: [Circular *3],
      '$parent': undefined,
      '$root': [Circular *3],
      '$children': [],
      '$refs': {},
      _watcher: null,
      _inactive: null,
      _directInactive: false,
      _isMounted: false,
      _isDestroyed: false,
      _isBeingDestroyed: false,
      _events: [Object: null prototype],
      _hasHookEvent: true,
      _vnode: null,
      _staticTrees: null,
      '$vnode': undefined,
      '$slots': {},
      '$scopedSlots': {},
      _c: [Function (anonymous)],
      '$createElement': [Function (anonymous)],
      '$attrs': [Getter/Setter],
      '$listeners': [Getter/Setter],
      _routerRoot: [Circular *3],
      _bv__modal: [BvModal],
      _bv__toast: [BvToast],
      _watchers: [],
      _data: {}
    },
    _makeLocalGettersCache: [Object: null prototype] {},
    dispatch: [Function: boundDispatch],
    commit: [Function: boundCommit],
    strict: true,
    getters: {},
    _vm: <ref *4> Vue {
      _uid: 12,
      _isVue: true,
      '$options': [Object],
      _renderProxy: [Circular *4],
      _self: [Circular *4],
      '$parent': undefined,
      '$root': [Circular *4],
      '$children': [],
      '$refs': {},
      _watcher: null,
      _inactive: null,
      _directInactive: false,
      _isMounted: false,
      _isDestroyed: false,
      _isBeingDestroyed: false,
      _events: [Object: null prototype],
      _hasHookEvent: true,
      _vnode: null,
      _staticTrees: null,
      '$vnode': undefined,
      '$slots': {},
      '$scopedSlots': {},
      _c: [Function (anonymous)],
      '$createElement': [Function (anonymous)],
      '$attrs': [Getter/Setter],
      '$listeners': [Getter/Setter],
      _routerRoot: [Circular *4],
      _bv__modal: [BvModal],
      _bv__toast: [BvToast],
      _watchers: [Array],
      _data: [Object],
      _computedWatchers: [Object: null prototype] {}
    },
    '$router': VueRouter {
      app: [Vue],
      apps: [Array],
      options: [Object],
      beforeHooks: [],
      resolveHooks: [],
      afterHooks: [],
      matcher: [Object],
      fallback: false,
      mode: 'abstract',
      history: [AbstractHistory],
      push: [Function: push],
      resolve: [Function (anonymous)]
    },
    registerModule: [Function: registerModule],
    app: <ref *1> {
      head: [Object],
      store: [Circular *5],
      router: [VueRouter],
      nuxt: [Object],
      render: [Function: render],
      data: [Function: data],
      beforeCreate: [Function: beforeCreate],
      created: [Function: created],
      mounted: [AsyncFunction: mounted],
      watch: [Object],
      computed: [Object],
      methods: [Object],
      components: [Object],
      context: [Circular *2],
      '$config': [Object],
      '$cookies': [Object],
      '$icon': [Function: getIcon],
      '$axios': [Function]
    },
    '$config': { baseURL: '/api', _app: [Object] },
    '$cookies': {
      parseJSON: true,
      set: [Function: set],
      setAll: [Function: setAll],
      get: [Function: get],
      getAll: [Function: getAll],
      remove: [Function: remove],
      removeAll: [Function: removeAll],
      nodeCookie: [Object]
    },
    '$icon': [Function: getIcon],
    '$axios': [Function: wrap] {
      request: [Function: wrap],
      getUri: [Function: wrap],
      delete: [Function: wrap],
      get: [Function: wrap],
      head: [Function: wrap],
      options: [Function: wrap],
      post: [Function: wrap],
      put: [Function: wrap],
      patch: [Function: wrap],
      defaults: [Object],
      interceptors: [Object],
      CancelToken: [Function],
      isCancel: [Function: isCancel],
      setBaseURL: [Function: bound setBaseURL],
      setHeader: [Function: bound setHeader],
      setToken: [Function: bound setToken],
      onRequest: [Function: bound onRequest],
      onResponse: [Function: bound onResponse],
      onRequestError: [Function: bound onRequestError],
      onResponseError: [Function: bound onResponseError],
      onError: [Function: bound onError],
      create: [Function: bound create],
      '$request': [Function: bound ],
      '$delete': [Function: bound ],
      '$get': [Function: bound ],
      '$head': [Function: bound ],
      '$options': [Function: bound ],
      '$post': [Function: bound ],
      '$put': [Function: bound ],
      '$patch': [Function: bound ]
    }
  },
  payload: undefined,
  error: [Function: bound error],
  base: '/',
  env: {},
  req: IncomingMessage {
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: [],
      flowing: null,
      ended: true,
      endEmitted: false,
      reading: false,
      sync: true,
      needReadable: false,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      errorEmitted: false,
      emitClose: true,
      autoDestroy: false,
      destroyed: false,
      errored: null,
      closed: false,
      closeEmitted: false,
      defaultEncoding: 'utf8',
      awaitDrainWriters: null,
      multiAwaitDrain: false,
      readingMore: true,
      decoder: null,
      encoding: null,
      [Symbol(kPaused)]: null
    },
    _events: [Object: null prototype] { end: [Function: clearRequestTimeout] },
    _eventsCount: 1,
    _maxListeners: undefined,
    socket: Socket {
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: null,
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 8,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: [Server],
      _server: [Server],
      parser: [HTTPParser],
      on: [Function: socketListenerWrap],
      addListener: [Function: socketListenerWrap],
      prependListener: [Function: socketListenerWrap],
      _paused: false,
      _peername: [Object],
      _httpMessage: [ServerResponse],
      [Symbol(async_id_symbol)]: 196676,
      [Symbol(kHandle)]: [TCP],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(RequestTimeout)]: undefined
    },
    httpVersionMajor: 1,
    httpVersionMinor: 1,
    httpVersion: '1.1',
    complete: true,
    headers: {
      host: '127.0.0.1:8000',
      connection: 'keep-alive',
      'cache-control': 'max-age=0',
      'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96"',
      'sec-ch-ua-mobile': '?0',
      'sec-ch-ua-platform': '"Windows"',
      'upgrade-insecure-requests': '1',
      'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36',
      accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
      'sec-fetch-site': 'none',
      'sec-fetch-mode': 'navigate',
      'sec-fetch-user': '?1',
      'sec-fetch-dest': 'document',
      'accept-encoding': 'gzip, deflate, br',
      'accept-language': 'zh-CN,zh;q=0.9'
    },
    rawHeaders: [
      'Host',
      '127.0.0.1:8000',
      'Connection',
      'keep-alive',
      'Cache-Control',
      'max-age=0',
      'sec-ch-ua',
      '" Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96"',
      'sec-ch-ua-mobile',
      '?0',
      'sec-ch-ua-platform',
      '"Windows"',
      'Upgrade-Insecure-Requests',
      '1',
      'User-Agent',
      'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36',
      'Accept',
      'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
      'Sec-Fetch-Site',
      'none',
      'Sec-Fetch-Mode',
      'navigate',
      'Sec-Fetch-User',
      '?1',
      'Sec-Fetch-Dest',
      'document',
      'Accept-Encoding',
      'gzip, deflate, br',
      'Accept-Language',
      'zh-CN,zh;q=0.9'
    ],
    trailers: {},
    rawTrailers: [],
    aborted: false,
    upgrade: false,
    url: '/',
    method: 'GET',
    statusCode: null,
    statusMessage: null,
    client: Socket {
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: null,
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 8,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: [Server],
      _server: [Server],
      parser: [HTTPParser],
      on: [Function: socketListenerWrap],
      addListener: [Function: socketListenerWrap],
      prependListener: [Function: socketListenerWrap],
      _paused: false,
      _peername: [Object],
      _httpMessage: [ServerResponse],
      [Symbol(async_id_symbol)]: 196676,
      [Symbol(kHandle)]: [TCP],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(RequestTimeout)]: undefined
    },
    _consuming: false,
    _dumped: false,
    originalUrl: '/',
    _parsedUrl: Url {
      protocol: null,
      slashes: null,
      auth: null,
      host: null,
      port: null,
      hostname: null,
      hash: null,
      search: null,
      query: null,
      pathname: '/',
      path: '/',
      href: '/',
      _raw: '/'
    },
    _parsedOriginalUrl: Url {
      protocol: null,
      slashes: null,
      auth: null,
      host: null,
      port: null,
      hostname: null,
      hash: null,
      search: null,
      query: null,
      pathname: '/',
      path: '/',
      href: '/',
      _raw: '/'
    },
    [Symbol(kCapture)]: false,
    [Symbol(RequestTimeout)]: undefined
  },
  res: <ref *6> ServerResponse {
    _events: [Object: null prototype] { finish: [Function: bound resOnFinish] },
    _eventsCount: 1,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    destroyed: false,
    _last: false,
    chunkedEncoding: false,
    shouldKeepAlive: true,
    _defaultKeepAlive: true,
    useChunkedEncodingByDefault: true,
    sendDate: true,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    _contentLength: null,
    _hasBody: true,
    _trailer: '',
    finished: false,
    _headerSent: false,
    socket: Socket {
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: null,
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 8,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: [Server],
      _server: [Server],
      parser: [HTTPParser],
      on: [Function: socketListenerWrap],
      addListener: [Function: socketListenerWrap],
      prependListener: [Function: socketListenerWrap],
      _paused: false,
      _peername: [Object],
      _httpMessage: [Circular *6],
      [Symbol(async_id_symbol)]: 196676,
      [Symbol(kHandle)]: [TCP],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(RequestTimeout)]: undefined
    },
    _header: null,
    _keepAliveTimeout: 5000,
    _onPendingData: [Function: bound updateOutgoingData],
    _sent100: false,
    _expect_continue: false,
    locals: {},
    statusCode: 200,
    [Symbol(kCapture)]: false,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: null
  },
  ssrContext: {
    req: IncomingMessage {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      socket: [Socket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      headers: [Object],
      rawHeaders: [Array],
      trailers: {},
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '/',
      method: 'GET',
      statusCode: null,
      statusMessage: null,
      client: [Socket],
      _consuming: false,
      _dumped: false,
      originalUrl: '/',
      _parsedUrl: [Url],
      _parsedOriginalUrl: [Url],
      [Symbol(kCapture)]: false,
      [Symbol(RequestTimeout)]: undefined
    },
    res: <ref *6> ServerResponse {
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: false,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: true,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: null,
      _hasBody: true,
      _trailer: '',
      finished: false,
      _headerSent: false,
      socket: [Socket],
      _header: null,
      _keepAliveTimeout: 5000,
      _onPendingData: [Function: bound updateOutgoingData],
      _sent100: false,
      _expect_continue: false,
      locals: {},
      statusCode: 200,
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: null
    },
    url: '/',
    target: 'server',
    spa: undefined,
    modern: false,
    runtimeConfig: { private: [Object], public: [Object] },
    _registeredComponents: Set(0) {},
    styles: [Getter],
    _renderStyles: [Function: renderStyles],
    _styles: {
      '71f83a6d:0': [Object],
      '32df6d42:0': [Object],
      '2998b330:0': [Object]
    },
    redirected: false,
    next: [Function (anonymous)],
    beforeRenderFns: [],
    nuxt: {
      layout: 'home',
      data: [],
      fetch: {},
      error: null,
      state: null,
      serverRendered: true,
      routePath: '/',
      config: [Object]
    },
    fetchCounters: {},
    meta: {
      getOptions: [Function: getOptions$1],
      setOptions: [Function: setOptions],
      refresh: [Function: refresh$1],
      inject: [Function: inject$1],
      pause: [Function: pause$1],
      resume: [Function: resume$1],
      addApp: [Function: addApp$1]
    },
    asyncData: {}
  },
  redirect: [Function (anonymous)],
  beforeNuxtRender: [Function (anonymous)],
  route: {
    name: 'index',
    meta: [ {} ],
    path: '/',
    hash: '',
    query: {},
    params: {},
    fullPath: '/',
    matched: [ [Object] ]
  },
  next: [Function (anonymous)],
  _redirected: false,
  _errored: false,
  params: {},
  query: {},
  '$config': {
    baseURL: '/api',
    _app: { basePath: '/', assetsPath: '/_nuxt/', cdnURL: null }
  },
  '$cookies': {
    parseJSON: true,
    set: [Function: set],
    setAll: [Function: setAll],
    get: [Function: get],
    getAll: [Function: getAll],
    remove: [Function: remove],
    removeAll: [Function: removeAll],
    nodeCookie: { parse: [Function: o], serialize: [Function: n] }
  },
  '$icon': [Function: getIcon],
  '$axios': [Function: wrap] {
    request: [Function: wrap],
    getUri: [Function: wrap],
    delete: [Function: wrap],
    get: [Function: wrap],
    head: [Function: wrap],
    options: [Function: wrap],
    post: [Function: wrap],
    put: [Function: wrap],
    patch: [Function: wrap],
    defaults: {
      headers: [Object],
      baseURL: 'http://localhost:8000/',
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      adapter: [Function: httpAdapter],
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: [Function: validateStatus],
      transitional: [Object]
    },
    interceptors: { request: [InterceptorManager], response: [InterceptorManager] },
    CancelToken: [Function: CancelToken] { source: [Function: source] },
    isCancel: [Function: isCancel],
    setBaseURL: [Function: bound setBaseURL],
    setHeader: [Function: bound setHeader],
    setToken: [Function: bound setToken],
    onRequest: [Function: bound onRequest],
    onResponse: [Function: bound onResponse],
    onRequestError: [Function: bound onRequestError],
    onResponseError: [Function: bound onResponseError],
    onError: [Function: bound onError],
    create: [Function: bound create],
    '$request': [Function: bound ],
    '$delete': [Function: bound ],
    '$get': [Function: bound ],
    '$head': [Function: bound ],
    '$options': [Function: bound ],
    '$post': [Function: bound ],
    '$put': [Function: bound ],
    '$patch': [Function: bound ]
  }
}

 

posted @ 2021-11-23 10:53  blurs  阅读(174)  评论(0编辑  收藏  举报