-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
80 lines (60 loc) · 2.09 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import {Cart} from "./Classes/Cart.js"
const cart = new Cart();
import {getAPIdata} from "./Classes/GetRemoteData.js";
import {Home} from "./Routes/Home.js";
import {About} from "./Routes/About.js";
import {CartRoute} from "./Routes/CartRoute.js";
import {Collections} from "./Routes/Collections.js";
import {Contacts} from "./Routes/Contacts.js";
import {Item} from "./Routes/Item.js";
// import {Carousel} from './Routes/Carousel.js'
const routes = [
{ path: '/', name:'Home', component: Home },
{ path: '/about', name:'About',component: About },
{ path: '/cart', name:'CartRoute',component: CartRoute},
{ path: '/collections', name:'Collections',component: Collections },
{ path: '/contacts', name:'Contacts',component: Contacts },
{ path: '/item/:xxx', name:"Item",component: Item },
// { path: '/carousel', name: 'Carousel', component: Carousel }
];
const router = VueRouter.createRouter({
history: VueRouter.createWebHashHistory(),
routes, // short for `routes: routes`
})
const app = Vue.createApp({
data(){
return{
items:[],
cart:cart,
}
},
created(){
this.fetcher();
},
methods:{
getMainColor(item){
let {red,green,blue,alpha} = item.borderInfo.dominatingColor;
item.mainColor = `rgba(${red},${green},${blue},${alpha})`; //преобладающий цвет на фото
return item.mainColor
},
async fetcher(){//---импорт сырого фетчА и его приготовление------
try{
let respObject = await getAPIdata().then(response => response.json());
this.items = respObject.items;
//console.table(this.items)
} catch(e){ console.error(`Error from App.vue/created(): `,e)}
},
},
computed:{
},
mounted(){
},
watch:{
}
})
app.use(router);
app.mount('#app');
//---------- эта штука показывает эвент-таргеты---------------------
document.onclick = function(){
//console.log(event.target)
}