Vue
by Damian Dulisz
HTML
<script src="https://unpkg.com/[email protected]/dist/axios.js"></script>
<div id="app">
<p>These are my workouts</p>
<ul>
<li v-for="(workout, index) in workouts" :key="index">
{{ workout.name }}
</li>
</ul>
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
Vue
Vue.component('lazy-wrapper', {
functional: true,
props: {
loading: {
type: Boolean,
}
},
render(createElement, { props, children }) {
return props.loading ? createElement('p', 'loading content...') : children;
}
})
new Vue({
el: "#app",
data: {
loading: true,
},
mounted() {
setTimeout(() => {
this.loading = false;
this.workouts = [
{ name: 'Abs', duration: 60 },
{ name: 'Legs', duration: 45 },
{ name: 'Shoulders', duration: 30 },
]
}, 1500);
}
})