Nuxt.js: Head scripts not inited in mount when route with nuxt-link

Created on 18 Jan 2019  路  4Comments  路  Source: nuxt/nuxt.js

Version

v2.3.4

Reproduction link

https://codesandbox.io/s/wn8ovky868

Steps to reproduce

Open index page then click to link "Go to the test page".
In console will "undefined".
But when you just open "/test" in browser you will see "ace" object in console.

What is expected ?

ace object in console

What is actually happening?

ace object is undefined

This bug report is available on Nuxt community (#c8502)
bug-report stale

Most helpful comment

Hi there,

I tried your code, as you can see in network tab, ace is correctly loaded and nuxt does its part.

You're trying to use an asynchronously loaded script which you don't know if it's actually really loaded at vue mounted lifecycle hook.

You could do this :
https://codesandbox.io/s/jvp7o9z0ny

@Atinux I'll open an feature request in vue-meta because we can't simply put an onload event using a component method like :

{
  src: "https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js",
  async: true,
  onload: this.myMethod // method isn't window exposed so it's "normal" but it could be better
}

All 4 comments

Hi there,

I tried your code, as you can see in network tab, ace is correctly loaded and nuxt does its part.

You're trying to use an asynchronously loaded script which you don't know if it's actually really loaded at vue mounted lifecycle hook.

You could do this :
https://codesandbox.io/s/jvp7o9z0ny

@Atinux I'll open an feature request in vue-meta because we can't simply put an onload event using a component method like :

{
  src: "https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js",
  async: true,
  onload: this.myMethod // method isn't window exposed so it's "normal" but it could be better
}

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as 馃晲Pending will not be automatically marked as stale.

@benoitemile Feel free to raise an issue or send in a PR on https://github.com/nuxt/vue-meta :relaxed:

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as 馃晲Pending will not be automatically marked as stale.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLoy picture VincentLoy  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

msudgh picture msudgh  路  3Comments

bimohxh picture bimohxh  路  3Comments

mattdharmon picture mattdharmon  路  3Comments