Bonjour à tous ;)
Je suis débutant en Code et Javascript et je suis entrain de créer mon porfolio avec VueJS en SPA et j'essaye plusieurs sliders sur ma HomePage. J'ai intégré cette fois ci un autre slider que j'ai trouvé aussi sur Codrops : https://tympanus.net/Development/OutdoorsTemplate/
Lorsque je lance mon app , la page charge indéfinement avec un loader et aucun élements de la page ne se charge. J'ai deux erreurs dans la console avec le message " "ReferenceError: imagesLoaded is not defined". Pourtant la fonction est bien défini dans le fichier javascript et j'ai bien lier le fichier " imagesloaded.pkgd.min.js " à mon app.
Voici mon code :
main.js
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
//import the vue instance
import Vue from 'vue'
//import the App component
import App from './App'
//import the vue router
import VueRouter from 'vue-router'
//tell vue to use the router
Vue.use(VueRouter)
/* eslint-disable no-new */
//import the hello component
import Hello from './components/Hello'
//import the about component
import About from './components/About'
//define your routes
const routes = [
//route for the home route of the webpage
{ path: '/', component: Hello },
//route for the about route of the webpage
{ path: '/about', component: About }
]
// Create the router instance and pass the `routes` option
// You can pass in additional options here, but let's
// keep it simple for now.
const router = new VueRouter({
routes, // short for routes: routes
mode: 'history'
})
//instatinat the vue instance
new Vue({
//define the selector for the root component
el: '#app',
//pass the template to the root component
template: '<App/>',
//declare components that the root component can access
components: { App },
//pass in the router to the vue instance
router
}).$mount('#app')//mount the router on the app
App.vue
<template>
<div id="app">
<nav class="demos">
<!-- the router outlet, where all matched components would ber viewed -->
<router-link v-bind:to="'/'">Home</router-link>
<router-link v-bind:to="'/about'">About</router-link>
</nav>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'app'
}
</script>
<!-- styling for the component -->
Hello.vue
<template>
<div id="hello">
<html lang="en" class="no-js">
<body class="loading">
<svg class="hidden">
<symbol id="icon-arrow" viewBox="0 0 24 24">
<title>arrow</title>
<polygon points="6.3,12.8 20.9,12.8 20.9,11.2 6.3,11.2 10.2,7.2 9,6 3.1,12 9,18 10.2,16.8 "/>
</symbol>
<symbol id="icon-drop" viewBox="0 0 24 24">
<title>drop</title>
<path d="M12,21c-3.6,0-6.6-3-6.6-6.6C5.4,11,10.8,4,11.4,3.2C11.6,3.1,11.8,3,12,3s0.4,0.1,0.6,0.3c0.6,0.8,6.1,7.8,6.1,11.2C18.6,18.1,15.6,21,12,21zM12,4.8c-1.8,2.4-5.2,7.4-5.2,9.6c0,2.9,2.3,5.2,5.2,5.2s5.2-2.3,5.2-5.2C17.2,12.2,13.8,7.3,12,4.8z"/><path d="M12,18.2c-0.4,0-0.7-0.3-0.7-0.7s0.3-0.7,0.7-0.7c1.3,0,2.4-1.1,2.4-2.4c0-0.4,0.3-0.7,0.7-0.7c0.4,0,0.7,0.3,0.7,0.7C15.8,16.5,14.1,18.2,12,18.2z"/>
</symbol>
<symbol id="icon-menu" viewBox="0 0 24 13">
<title>menu</title>
<path d="M.75 1.515h22.498a.75.75 0 0 0 0-1.5H.75a.75.75 0 0 0 0 1.5zM23.248 5.265H8.168a.75.75 0 0 0 0 1.5h15.08a.75.75 0 0 0 0-1.5zM23.248 10.514H4.322a.75.75 0 0 0 0 1.5h18.926a.75.75 0 0 0 0-1.5z"/>
</symbol>
<symbol id="icon-dot" viewBox="0 0 24 24">
<title>dot</title>
<path d="M11.5 9c-.69 0-1.28.244-1.768.732A2.41 2.41 0 0 0 9 11.5c0 .69.244 1.28.732 1.767A2.409 2.409 0 0 0 11.5 14c.69 0 1.28-.244 1.768-.733A2.408 2.408 0 0 0 14 11.5c0-.69-.244-1.28-.732-1.768A2.408 2.408 0 0 0 11.5 9z"/>
</symbol>
<symbol id="icon-cross" viewBox="0 0 24 24">
<title>cross</title>
<path d="M11.449 11.962l-5.1 5.099a.363.363 0 1 0 .513.512L12 12.436l5.137 5.137a.361.361 0 0 0 .513 0 .363.363 0 0 0 0-.512l-5.099-5.1 5.102-5.102a.363.363 0 1 0-.512-.513L12 11.487l-5.141-5.14a.363.363 0 0 0-.513.512l5.103 5.103z"/>
</symbol>
<symbol id="icon-arrowlong" viewBox="0 0 32 11">
<title>arrow-long</title>
<path d="M27.166.183a.619.619 0 0 0-.878 0 .619.619 0 0 0 0 .878l2.735 2.735H.768a.624.624 0 0 0 0 1.248h28.254L26.287 7.77a.619.619 0 0 0 0 .878.617.617 0 0 0 .441.183c.163 0 .32-.061.442-.183l3.796-3.796a.623.623 0 0 0-.005-.878L27.166.183z"/>
</symbol>
<symbol id="icon-close" viewBox="0 0 24 24">
<title>close</title>
<path d="M21 4.565L19.435 3 12 10.435 4.565 3 3 4.565 10.435 12 3 19.435 4.565 21 12 13.565 19.435 21 21 19.435 13.565 12z"/>
</symbol>
<symbol id="icon-navup" viewBox="0 0 50 50">
<title>navup</title>
<path d="M20.259 28.211l5.07-5.03 5.075 5.034a.36.36 0 0 0 .51 0 .356.356 0 0 0 0-.506l-5.323-5.28a.404.404 0 0 0-.135-.084.364.364 0 0 0-.384.08l-5.324 5.28a.356.356 0 0 0 0 .506c.141.14.37.14.51 0z" />
</symbol>
<symbol id="icon-navdown" viewBox="0 0 50 50">
<title>navdown</title>
<path d="M20.259 22.43l5.07 5.03 5.075-5.034a.36.36 0 0 1 .51 0c.14.14.14.366 0 .506l-5.323 5.28a.404.404 0 0 1-.135.084.364.364 0 0 1-.384-.081l-5.324-5.28a.356.356 0 0 1 0-.505c.141-.14.37-.14.51 0z" />
</symbol>
<symbol id="icon-grid" viewBox="0 0 24 24">
<title>grid</title>
<path d="M8.982 8.982h5.988v5.988H8.982zM0 0h5.988v5.988H0zM8.982 17.965h5.988v5.988H8.982zM0 8.982h5.988v5.988H0zM0 17.965h5.988v5.988H0zM17.965 0h5.988v5.988h-5.988zM8.982 0h5.988v5.988H8.982zM17.965 8.982h5.988v5.988h-5.988zM17.965 17.965h5.988v5.988h-5.988z"/>
</symbol>
</svg>
<main>
<div class="sections">
<header class="sections__header">
<h1 class="title">Outdoors</h1>
</header>
<!-- codrops links -->
<div class="codrops-links">
<a class="codrops-icon codrops-icon--prev" href="https://tympanus.net/Development/GradientTopographyAnimation/" title="Previous Demo"><svg class="icon icon--arrow"><use xlink:href="#icon-arrow"></use></svg></a>
<a class="codrops-icon codrops-icon--drop" href="https://tympanus.net/codrops/?p=33851" title="Back to the article"><svg class="icon icon--drop"><use xlink:href="#icon-drop"></use></svg></a>
</div>
<!-- menu -->
<nav class="menu">
<ul class="menu__inner">
<li class="menu__item"><a class="menu__item-link" href="#">Our Story</a></li>
<li class="menu__item"><a class="menu__item-link" href="#">Adventures</a></li>
<li class="menu__item"><a class="menu__item-link" href="#">Testimonials</a></li>
<li class="menu__item"><a class="menu__item-link" href="#">Contact</a></li>
</ul>
<div class="menu__toggle">
<span class="menu__toggle-inner menu__toggle-inner--open">
<svg class="icon icon--menu"><use xlink:href="#icon-menu"></use></svg>
</span>
<span class="menu__toggle-inner menu__toggle-inner--close">
<svg class="icon icon--close"><use xlink:href="#icon-close"></use></svg>
</span>
</div>
</nav>
<!-- facts expander with toggles; content for each is in its section -->
<div class="facts">
<div class="facts__toggle">
<span class="facts__toggle-inner facts__toggle-inner--more">
<svg class="icon icon--dot"><use xlink:href="#icon-dot"></use></svg>
<span class="facts__toggle-text">See more facts</span>
</span>
<span class="facts__toggle-inner facts__toggle-inner--less">
<svg class="icon icon--cross"><use xlink:href="#icon-cross"></use></svg>
<span class="facts__toggle-text">See less facts</span>
</span>
</div>
<button class="button-contentclose">
<svg class="icon icon--close"><use xlink:href="#icon-close"></use></svg>
</button>
</div>
<!-- index -->
<div class="sections__index">
<span class="sections__index-current">
<span class="sections__index-inner">01</span>
</span>
<span class="sections__index-total">04</span>
</div>
<!-- navigation down -->
<nav class="sections__nav">
<button class="sections__nav-item sections__nav-item--prev">
<svg class="icon icon--navup"><use xlink:href="#icon-navup"></use></svg>
</button>
<button class="sections__nav-item sections__nav-item--next">
<svg class="icon icon--navdown"><use xlink:href="#icon-navdown"></use></svg>
</button>
</nav>
<!-- sections -->
<section class="section section--current">
<div class="section__content">
<h2 class="section__title">Hiking</h2>
<p class="section__description"><span class="section__description-inner">Hiking is the preferred term, in Canada and the United States, for a long, vigorous walk, usually on trails (footpaths), in the countryside, while the word walking is used for shorter, particularly urban walks.</span></p>
</div>
<div class="section__img">
<div class="section__img-inner" style="background-image: url(../static/1.jpg)"></div>
</div>
<div class="section__more">
<div class="section__more-inner section__more-inner--bg1">
<span class="section__more-text">Want to know more?</span>
<a href="#" class="section__more-link">
<span class="section__more-linktext">Explore all hikes</span>
<svg class="icon icon--arrowlong"><use xlink:href="#icon-arrowlong"></use></svg>
</a>
</div>
</div>
<div class="section__expander"></div>
<ul class="section__facts">
<li class="section__facts-item">
<h3 class="section__facts-title">Biggest lake</h3>
<span class="section__facts-detail">Caspian sea in Kazakhstan</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">Coolest activity</h3>
<span class="section__facts-detail">Kayaking the whole lake</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">Lake depth</h3>
<span class="section__facts-detail">With 55m it's the deepest</span>
</li>
<li class="section__facts-item section__facts-item--clickable" data-gallery="gallery1">
<div class="section__facts-img">
<img src="img/thumb1.jpg" alt="Some image"/>
<svg class="icon icon--grid"><use xlink:href="#icon-grid"></use></svg>
</div>
<h3 class="section__facts-title">More impressions</h3>
<span class="section__facts-detail">A collection of images</span>
</li>
</ul>
<div class="section__gallery" id="gallery1">
<h3 class="section__gallery-item section__gallery-item--title">More impressions</h3>
<a class="section__gallery-item" href="#"><img src="/static/thumb1.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb2.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb3.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb4.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb5.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb6.jpg" alt="Some image"/></a>
</div>
</section><!--/ section -->
<section class="section">
<div class="section__content">
<h2 class="section__title">Lakes</h2>
<p class="section__description"><span class="section__description-inner">A lake is an area filled with water, localized in a basin, that is surrounded by land, apart from any river or other outlet that serves to feed or drain the lake. Lakes lie on land and are not part of the ocean.</span></p>
</div>
<div class="section__img">
<div class="section__img-inner" style="background-image: url(../static/2.jpg)"></div>
</div>
<div class="section__more">
<div class="section__more-inner section__more-inner--bg2">
<span class="section__more-text">Want to know more?</span>
<a href="#" class="section__more-link">
<span class="section__more-linktext">Explore the lakes</span>
<svg class="icon icon--arrowlong"><use xlink:href="#icon-arrowlong"></use></svg>
</a>
</div>
</div>
<div class="section__expander"></div>
<ul class="section__facts">
<li class="section__facts-item">
<h3 class="section__facts-title">Biggest lake</h3>
<span class="section__facts-detail">Caspian sea in Kazakhstan</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">Coolest activity</h3>
<span class="section__facts-detail">Kayaking the whole lake</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">Lake depth</h3>
<span class="section__facts-detail">With 55m it's the deepest</span>
</li>
<li class="section__facts-item section__facts-item--clickable" data-gallery="gallery2">
<div class="section__facts-img">
<img src="img/thumb2.jpg" alt="Some image"/>
<svg class="icon icon--grid"><use xlink:href="#icon-grid"></use></svg>
</div>
<h3 class="section__facts-title">More impressions</h3>
<span class="section__facts-detail">A collection of images</span>
</li>
</ul>
<div class="section__gallery" id="gallery2">
<h3 class="section__gallery-item section__gallery-item--title">More impressions</h3>
<a class="section__gallery-item" href="#"><img src="/static/thumb5.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb6.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb1.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb2.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb3.jpg" alt="Some image"/></a>
<a class="section__gallery-item" href="#"><img src="/static/thumb4.jpg" alt="Some image"/></a>
</div>
</section><!--/ section -->
<section class="section">
<div class="section__content">
<h2 class="section__title">Paths</h2>
<p class="section__description"><span class="section__description-inner">A footpath (also pedestrian way, walking trail, nature trail) is a type of thoroughfare that is intended for use only by pedestrians and not other forms of traffic such as motorized vehicles, cycles, and horses.</span></p>
</div>
<div class="section__img">
<div class="section__img-inner" style="background-image: url(../static/3.jpg)"></div>
</div>
<div class="section__more">
<div class="section__more-inner section__more-inner--bg3">
<span class="section__more-text">Want to know more?</span>
<a href="#" class="section__more-link">
<span class="section__more-linktext">Explore the paths</span>
<svg class="icon icon--arrowlong"><use xlink:href="#icon-arrowlong"></use></svg>
</a>
</div>
</div>
<div class="section__expander"></div>
<ul class="section__facts">
<li class="section__facts-item">
<h3 class="section__facts-title">Lovely paths</h3>
<span class="section__facts-detail">Caspian sea in Kazakhstan</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">Haunted ways</h3>
<span class="section__facts-detail">Kayaking the whole lake</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">Running and more</h3>
<span class="section__facts-detail">With 55m it's the deepest</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">Starting to walk</h3>
<span class="section__facts-detail">An aerial view of the lake</span>
</li>
</ul>
</section><!--/ section -->
<section class="section">
<div class="section__content">
<h2 class="section__title">Rivers</h2>
<p class="section__description"><span class="section__description-inner">A river is a natural flowing watercourse, usually freshwater, flowing towards an ocean, sea, lake or another river. In some cases a river flows into the ground and becomes dry at the end of its course without reaching another body of water.</span></p>
</div>
<div class="section__img">
<div class="section__img-inner" style="background-image: url(../static/4.jpg)"></div>
</div>
<div class="section__more">
<div class="section__more-inner section__more-inner--bg4">
<span class="section__more-text">Want to know more?</span>
<a href="#" class="section__more-link">
<span class="section__more-linktext">Explore all rivers</span>
<svg class="icon icon--arrowlong"><use xlink:href="#icon-arrowlong"></use></svg>
</a>
</div>
</div>
<div class="section__expander"></div>
<ul class="section__facts">
<li class="section__facts-item">
<h3 class="section__facts-title">River romantics</h3>
<span class="section__facts-detail">Caspian sea in Kazakhstan</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">History call</h3>
<span class="section__facts-detail">Kayaking the whole lake</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">Walking around</h3>
<span class="section__facts-detail">With 55m it's the deepest</span>
</li>
<li class="section__facts-item">
<h3 class="section__facts-title">How many miles?</h3>
<span class="section__facts-detail">An aerial view of the lake</span>
</li>
</ul>
</section><!--/ section -->
</div><!--/ sections -->
</main>
</body>
</html>
</div>
</template>
<script>
export default {
name: 'hello',
}
</script>
index.html
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Outdoors Template | Codrops</title>
<meta name="description" content="An implementation of Gil Huybrecht's Outdoors design" />
<meta name="keywords" content="template, web design, html, javascript, layout, css, slide out" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/static/normalize.css" />
<link rel="stylesheet" type="text/css" href="/static/style.css" />
<script>document.documentElement.className="js";var supportsCssVars=function(){var e,t=document.createElement("style");return t.innerHTML="root: { --tmp-var: bold; }",document.head.appendChild(t),e=!!(window.CSS&&window.CSS.supports&&window.CSS.supports("font-weight","var(--tmp-var)")),t.parentNode.removeChild(t),e};supportsCssVars()||alert("Please view this demo in a modern browser that supports CSS Variables.");</script>
<!--script src="//tympanus.net/codrops/adpacks/analytics.js"></script-->
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<script src="/static/imagesloaded.pkgd.min.js"></script>
<script src="/static/charming.min.js"></script>
<script src="/static/anime.min.js"></script>
<script src="/static/home.js"></script>
</html>
Le code complet de mon App est diponible sur Github : https://github.com/Alexsalicki91/Slider/tree/master/spa
J'ai remarqué que lorsque je supprime cette ligne de mon fichier index.html
<script>document.documentElement.className="js";var supportsCssVars=function(){var e,t=document.createElement("style");return t.innerHTML="root: { --tmp-var: bold; }",document.head.appendChild(t),e=!!(window.CSS&&window.CSS.supports&&window.CSS.supports("font-weight","var(--tmp-var)")),t.parentNode.removeChild(t),e};supportsCssVars()||alert("Please view this demo in a modern browser that supports CSS Variables.");</script>
la page arrive à charge et le slider aussi. Le slider fonctionne mais tous les élements de chaque slide sont supperposés. J'ai cherché sur des forums pour comprendre l'erreur " imageLoaded is not defined " mais je n'ai pas trouvé de solution à mon problème et j'ai besoin d'aide !
Il y a t'il des erreurs dans mon code ? Ai je oublié des lignes de codes importantes ? Pourquoi la page se charge indéfinement ? Pourquoi les élements de chaque slider sont supperposés ?
Bonne soirée à tous :)
Alex Salicki
Bonjour,
Il y a pas mal de petits trucs qui clochent à l'heure actuelle.
Hello.vue
, il ne devrait pas y avoir de balises html
, head
et body
.index.html
, les scripts doivent être chargés avant la fermeture du body.Une fois ceci corrigé, tu auras toujours le loader car le code dans slider.js
va demander quelques corrections.
Bonjour ,
Merci beaucoup pour votre réponse ! En changeant juste ce que vous avez dit dans votre message , le slider marche maintenant parfaitement bien ! :)