Skip to content

Commit 8592c2c

Browse files
committed
module warna
2 parents a5cdba0 + ded0b71 commit 8592c2c

File tree

14 files changed

+482
-439
lines changed

14 files changed

+482
-439
lines changed

public/js/app.js

Lines changed: 354 additions & 406 deletions
Large diffs are not rendered by default.

resources/assets/js/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
require('./bootstrap');
22
window.Vue = require('vue');
3+
import store from './store'
34

4-
Vue.component('vuex-example', require('./components/VuexExample.vue'));
5+
Vue.component('vuex-bahasa', require('./components/VuexBahasa.vue'));
56

67
const app = new Vue({
78
el: '#app',
9+
store
810
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<bahasa/>
3+
</template>
4+
5+
<script>
6+
//komponenn modul kemudian panggil diatas
7+
import bahasa from 'modul/Bahasa'
8+
9+
export default{
10+
name: 'VuexBahasa',//
11+
components: {
12+
bahasa //memanggil modul
13+
}
14+
}
15+
</script>

resources/assets/js/modul/frameProduct/store/action.js renamed to resources/assets/js/modul/FrameProduct/store/actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import axios from 'axios'
44

55
//function get data
6-
const getData= function getData(context){
6+
const getData = function getData(context){
77
axios
88
.get('https://api.nasa.gov/planetary/apod?api_key=NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo')
99
.then(response =>{
10-
context.comit('UPDATE_DATA1',response.data) //response.data untuk mengirim data dalam bentuk objek
10+
context.commit('UPDATE_DATA1',response.data) //response.data untuk mengirim data dalam bentuk objek
1111
});
1212
}
1313
export default{
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<template>
2+
<table class="table">
3+
<thead>
4+
<tr>
5+
<th scope="col">Album</th>
6+
<th scope="col">Id</th>
7+
<th scope="col">Title</th>
8+
<th scope="col">Image</th>
9+
</tr>
10+
</thead>
11+
<tbody v-for="warna2 in warna" :key="warna2.id">
12+
<td>{{ warna2.albumId}}</td>
13+
<td>{{ warna2.id }}</td>
14+
<td>{{ warna2.title }}</td>
15+
<td ><img v-bind:src="warna2.thumbnailUrl"> </td>
16+
</tbody>
17+
</table>
18+
</template>
19+
<script>
20+
import store from './store'
21+
import {mapActions,mapGetters} from 'vuex'
22+
23+
export default {
24+
name: 'Warna',
25+
created(){
26+
const STORE_KEY='$_warna';
27+
if(!(STORE_KEY in this.$store._modules.root._children)){ //mengecek store dengan nama store_key
28+
this.$store.registerModule(STORE_KEY,store)
29+
}
30+
},
31+
mounted(){
32+
this.$store.dispatch('$_warna/getDataWarna')
33+
},
34+
computed:{
35+
...mapGetters({
36+
warna:'$_warna/ragamWarna' //mengganti nnama data
37+
})
38+
}
39+
}
40+
</script>
41+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import axios from 'axios'
2+
3+
//function get data
4+
const getDataWarna = function getDataWarna(context){
5+
axios
6+
.get('https://jsonplaceholder.typicode.com/photos')
7+
.then(response =>{
8+
context.commit('RAGAM_WARNA',response.data) //response.data untuk mengirim data dalam bentuk objek
9+
});
10+
}
11+
export default{
12+
getDataWarna
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//menerima data dari muttions
2+
3+
const ragamWarna= function ragamWarna(state){
4+
return state.ragamWarna
5+
} //const digunakan untuk export data
6+
7+
export default{
8+
ragamWarna
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//file state
2+
3+
import actions from './actions'
4+
import mutations from './mutations'
5+
import getters from './getters'
6+
7+
const state={
8+
ragamWarna:{}
9+
}
10+
//untuk mengirim data1 ke index.vue / agar ke file yg membutuhkan
11+
export default{
12+
namespaced:true,
13+
state,
14+
actions,
15+
mutations,
16+
getters
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const RAGAM_WARNA=function RAGAM_WARNA(state,data){ //state mengakses data yang dipakai , data satu merupaka data yang dikirim dari action
2+
state.ragamWarna=data
3+
//segala operasi dilakukan disini
4+
}
5+
6+
export default{
7+
RAGAM_WARNA
8+
}

0 commit comments

Comments
 (0)