// store.js
export default {
a: 'foo',
b: 'bar'
}
import Vue from 'vue'
import Store from './store'
new Vue({
el: '#app',
data: Store,
render: h => h(App)
})
<template>
<div>{{$root.a}}</div>
</template>
<script>
import Store from './store'
export default {
name: 'app',
methods: {
test () {
this.$root.a = 'something value'
}
}
}
<map-point v-for="point in points" :key="point" :point="point"></map-point>
<map-point v-for="point in points" :key="point" v-bind="point"></map-point>
props['map_x', 'map_y']
<template>
<sort v-model="sortType"></sort>
<list :items="sortedItems"></list>
</template>
<script>
export default {
props: ['items'],
data() {
return {
sortType: 'byName'
}
},
computed: {
sortedItems() {
switch(this.sortType) {
case 'byName': return // sort by name
case 'bySomething': return // sort by something
}
}
}
}
</script>
var arr1 = [
{course_id: 50, name: "name 1"},
{course_id: 150, name: "name 2"},
{course_id: 100, name: "name 3"}
]
var arr2 = [
{course_id: 150},
{course_id: 50},
{course_id: 100}
]
var res = arr1.map((el,idx) => {
el.course_id = arr2[idx].course_id
return el
}).sort((a,b) => a.course_id-b.course_id)
console.log(res)