Skip to content
This repository was archived by the owner on May 14, 2023. It is now read-only.

Commit 8950fa3

Browse files
committed
Integrated Vue-Router and Clipboard.js
1 parent ef5516a commit 8950fa3

File tree

3 files changed

+68
-36
lines changed

3 files changed

+68
-36
lines changed

src/App.vue

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,16 @@
11
<template>
22
<div class="wrapper" id="app">
33
<bc-header></bc-header>
4-
<div class="page">
5-
<section class="search">
6-
<div class="container">
7-
<div class="box-1">
8-
<search-box></search-box>
9-
</div>
10-
</div>
11-
</section>
12-
<section class="brand">
13-
<div class="container">
14-
<brand-row v-for="item in colorData">
15-
<h2 slot="title">{{ item.name }}</h2>
16-
17-
<template v-for="color in item.colors">
18-
<color-box slot="colors" :color="color"></color-box>
19-
</template>
20-
</brand-row>
21-
</div>
22-
</section>
23-
</div>
4+
<router-view></router-view>
245
</div>
256
</template>
267

278
<script>
28-
/* eslint-disable object-shorthand */
29-
309
import BcHeader from './components/header.vue';
31-
import SearchBox from './components/search-box.vue';
32-
import BrandRow from './components/brand-row.vue';
33-
import ColorBox from './components/color-box.vue';
34-
35-
import colorData from './assets/data.json';
3610
3711
export default {
38-
data() {
39-
return {
40-
colorData: colorData,
41-
};
42-
},
4312
components: {
4413
BcHeader,
45-
SearchBox,
46-
BrandRow,
47-
ColorBox,
4814
},
4915
};
5016
</script>

src/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,23 @@ import Vue from 'vue';
55
import VueRouter from 'vue-router';
66
import App from './App.vue';
77

8+
import HomePage from './pages/Home.vue';
9+
810
import Style from './style.scss';
911

12+
Vue.use(VueRouter);
13+
14+
const routes = [
15+
{ path: '/', component: HomePage },
16+
];
17+
18+
const router = new VueRouter({
19+
mode: 'history',
20+
routes,
21+
});
22+
1023
const app = new Vue({
1124
el: '#app',
1225
render: h => h(App),
13-
});
26+
router,
27+
}).$mount('#app');

src/pages/Home.vue

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div class="page">
3+
<section class="search">
4+
<div class="container">
5+
<div class="box-1">
6+
<search-box></search-box>
7+
</div>
8+
</div>
9+
</section>
10+
<section class="brand">
11+
<div class="container">
12+
<brand-row v-for="item in colorData">
13+
<h2 slot="title">{{ item.name }}</h2>
14+
15+
<template v-for="color in item.colors">
16+
<color-box slot="colors" :color="color"></color-box>
17+
</template>
18+
</brand-row>
19+
</div>
20+
</section>
21+
</div>
22+
</template>
23+
24+
<script>
25+
/* eslint-disable object-shorthand */
26+
27+
import Clipboard from 'clipboard';
28+
29+
import SearchBox from '../components/search-box.vue';
30+
import BrandRow from '../components/brand-row.vue';
31+
import ColorBox from '../components/color-box.vue';
32+
33+
import colorData from '../assets/data.json';
34+
35+
export default {
36+
data() {
37+
return {
38+
colorData: colorData,
39+
};
40+
},
41+
components: {
42+
SearchBox,
43+
BrandRow,
44+
ColorBox,
45+
},
46+
created: function () {
47+
const clipboard = new Clipboard('.color-box');
48+
clipboard.on('success', () => {
49+
});
50+
},
51+
};
52+
</script>

0 commit comments

Comments
 (0)