A
A
Andrew2020-02-12 10:41:02
Vue.js
Andrew, 2020-02-12 10:41:02

How to ensure script loading in nuxt?

nuxt.config.js has the following lines:

script: [
            { src: 'https://api-maps.yandex.ru/2.1/?apikey=********&lang=ru_RU' }
        ],

Everything works fine on desktop, no problems. However, on a mobile device, when trying to access a page that uses maps, the ymaps is not defined error occurs, which indicates that the script did not load for some reason.

ymaps.ready() is used in mounted() hook

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aetae, 2020-02-12
@Aetae

I met situations when the cards were blocked by mobile "tracking protection". Just in case, check if the "shield" opposite the url is on.

A
Alex, 2020-02-12
@Kozack Vue.js

I will assume that the script is loaded with an attribute deferand it may happen that your component will be rendered before this script is loaded.
Try the solution I proposed here - How to correctly initialize the Yandex Maps API in ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question