<div id="app">
<p>{{ helloText }}</p>
</div>
const mylib = {
hello : (text1, text2) => {
return `Hello! ${text1} ${text2}`
},
install: function(Vue){
Object.defineProperty(Vue.prototype, 'mylib', {
get () { return mylib }
})
}
};
Vue.use(mylib);
new Vue({
el: '#app',
data: {
helloText: mylib.hello('one', 'two')
}
});
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<child></child>
</div>
Vue.component('child', {
props: {
card: {
type: Object,
default: function() {
return {
id: 0,
name: 'default name',
title: 'default title'
}
}
}
},
template: `<p>{{ card.id }} | {{ card.name }} | {{ card.title }}</p>`
});
new Vue({
el: '#app',
});
var i = array1.filter(al => {return !array2.map(bl => bl.id).includes(al.id)});
array1.filter(al => {return !array2.map(bl => bl.id).includes(al.id)}).map(l => l.id)
if (typeof record == 'object') {
if (record.quantity == 1) {
let i = state.added.findIndex(p => p.id === id);
state.added.splice(i,1);
//state.added.remove(record)
} else {
record.quantity--;
}
}
<div v-for="slide in slidesToShow" class="projects__item">
<div class="projects-info">
<div class="projects-info__title">{{ slide.title }}</div>
<div class="projects-info__description">{{ slide.text }}</div>
</div>
<div class="projects__play"></div>
<video class="projects__item-video" preloader="none" loop muted>
<source :src="slide.video" type="video/mp4">
</video>
</div>
<button @click="showMore()">More</button>
export default {
async asyncData () {
const { data } = await axios.get('https://ggproduction-f0b98.firebaseio.com/slides.json')
return { slides: data }
},
data: function () {
return {
nShow: 8, // изначально
nAdd: 2 // сколько добавляем
}
},
computed: {
slidesToShow: function() {
return this.slides.slice(0, this.nShow);
}
},
methods: {
showMore: function() {
this.nShow += this.nAdd;
}
}
}
import Button from './Button.vue'
components: {
'app-button': Button
}
<app-button></app-button>