简体   繁体   中英

Initialize and use Swup in Meteor js

I am trying to use swup in meteor js framework. I added the script tag that contains unpkg link for swup in main.html and initialized Swup in Meteor.startup function of main.js. But when i run the app, it is throwing "Cannot set property 'responseURL' of null" error.

in main.html:

<script src="unpkg.com/swup@latest/dist/swup.min.js"></script>  
<script>
    const swup = new Swup();
</script>

And added swup id to layout.html which is like the container in which all routing occurs.

I just recently started to work on Meteor, so i am a bit confused. I would be glad, if anyone could help me in initializing and setting up swup. Thanks in Advance.

Blaze strips any script tag including it's content to prevent XSS. Install swup via npm and import it in your Template to resolve this:

$ meteor npm install --save swup

and in your client/main.js you initialize swup:

import Swup from 'swup';
const swup = new Swup(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM