Last active
March 3, 2017 09:59
-
-
Save rdunk/1371389794270c9672bb15f4e24d40c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue = require('vue/dist/vue.common.js'); | |
VueRouter = require('vue-router'); | |
VueLazyload = require('vue-lazyload'); | |
Vue.use(VueRouter); | |
const Home = { | |
name: 'home', | |
template: "<div class=\"img\" v-lazy:background-image=\"'http://placehold.it/400x100'\"></div>" | |
}; | |
const Foo = { | |
name: 'foo', | |
template: "<div class=\"img\" v-lazy:background-image=\"'http://placehold.it/400x200'\"></div>" | |
} | |
const Bar = { | |
name: 'bar', | |
template: "<div class=\"img\" v-lazy:background-image=\"'http://placehold.it/400x300'\"></div>" | |
} | |
const routes = [ | |
{ | |
path: '', | |
component: Home, | |
}, { | |
path: '/one', | |
component: Foo, | |
}, { | |
path: '/two', | |
component: Bar, | |
}, | |
]; | |
const router = new VueRouter({ | |
mode: 'abstract', | |
routes: routes, | |
}); | |
Vue.use(VueLazyload, { | |
preLoad: 1.8, | |
error: false, | |
loading: false, | |
attempt: 3, | |
supportWebp: false, | |
}); | |
const app = new Vue({ | |
el: '#app', | |
router, | |
data: { | |
message: 'Hello Vue.js!' | |
} | |
}); | |
app.$Lazyload.$on('loaded', () => { | |
console.table(app.$Lazyload.performance()); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"vue-router": "2.3.0", | |
"vue-lazyload": "1.0.0-rc12", | |
"vue": "2.2.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<router-link to="/">Home</router-link> | |
<router-link to="/one">One</router-link> | |
<router-link to="/two">Two</router-link> | |
<router-view></router-view> | |
</div> | |
<style> | |
#app { | |
height: 400px; | |
overflow-y: scroll; | |
} | |
.img { | |
width: 400px; | |
height: 600px; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment