Skip to content

Commit 8e4ab7f

Browse files
author
alistar
committed
引入mint-ui vue-light-swiper vue-awesome-swiper 写一个test页
1 parent 5f18534 commit 8e4ab7f

File tree

12 files changed

+160
-8
lines changed

12 files changed

+160
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 94club.github.io
2-
#### 移动端demo, 完全学习https://github.com/zaofeng/vue2-elm
2+
#### 移动端demo, 完全学习https://github.com/bailicangdu/vue2-elm
33

44
# 项目布局
55

package-lock.json

Lines changed: 39 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
"better-scroll": "^1.12.1",
1616
"fastclick": "^1.0.6",
1717
"iscroll": "^5.2.0",
18+
"mint-ui": "^2.2.13",
1819
"showdown": "^1.8.6",
1920
"vue": "^2.5.2",
21+
"vue-awesome-swiper": "^2.6.7",
22+
"vue-light-swiper": "^1.0.9",
2023
"vue-router": "^3.0.1",
2124
"vuex": "^3.0.1"
2225
},

src/DemoDescription.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#### navbar 注意事项
2+
1 安装swiper3 npm i vue-awesome-swiper@2.6.7 -S
3+
2 每一个slide的width,强制auto
4+
TODO 数据异步获取 切换动画效果 上拉加载

src/commitDetail.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ css初始化 结构目录创建 03d02d43f7825424569c1b1b638255565026ca4e
44
移动端适配 路由懒加载 css书写方案 2498ba9725608131d7cc2eadea09daba108ce104
55
安装依赖 完成首页
66
npm i vuex showdown iscroll fastclick better-scroll axios -S
7-
npm i node-sass sass-loader http-proxy-middleware -D
7+
npm i node-sass sass-loader http-proxy-middleware -D
8+
5f18534dcb413eb2714da0f95e8ea4869ef489c4
9+
引入mint-ui vue-light-swiper vue-awesome-swiper 写一个test页(mint-ui暂时放在生产依赖)

src/components/common/test.vue

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<template>
2+
<div>
3+
<swiper :options="swiperOption" :not-next-tick="swiperOption.notNextTick" ref="swiper1">
4+
<!-- slides -->
5+
<swiper-slide
6+
v-for="(item, index) in floorNavData.list"
7+
:key="index"
8+
:class="{'is-active': floorNavData.activeIndex === index}"
9+
@click.native="onFloorNav(index)" class="auto-width">
10+
{{item}}
11+
</swiper-slide>
12+
</swiper>
13+
<swiper :options="swiperOption2" :not-next-tick="swiperOption2.notNextTick" ref="swiper2">
14+
<!-- slides -->
15+
<swiper-slide>I'm Slide {{floorNavData.activeIndex}}</swiper-slide>
16+
</swiper>
17+
</div>
18+
</template>
19+
<script>
20+
export default {
21+
data () {
22+
return {
23+
floorNavData: {
24+
list: ['PHONE', 'IP', 'MIFI', 'Air container', 'TF-card', 'earphone', 'xbox', 'wifi'],
25+
activeIndex: 0
26+
},
27+
index: 0,
28+
swiperOption: {
29+
slidesPerView: 'auto',
30+
spaceBetween: 10, // slide之间的距离(单位px)。
31+
freeMode: true, // 默认为false,普通模式:slide滑动时只滑动一格,并自动贴合wrapper,设置为true则变为free模式,slide会根据惯性滑动且不会贴合。
32+
loop: false // 是否可循环
33+
},
34+
swiperOption2: {
35+
direction: 'horizontal', // Slides的滑动方向,可设置水平(horizontal)或垂直(vertical)。
36+
loop: false,
37+
effect: 'fade', // 淡入
38+
// effect : 'cube', // 方块
39+
// effect : 'coverflow', // 3D流
40+
// effect : 'flip', // 3D翻转
41+
autoHeight: true, // 自动高度。设置为true时,wrapper和container会随着当前slide的高度而发生变化。
42+
onSlideChangeEnd: function () { // 回调函数,swiper从一个slide过渡到另一个slide结束时执行。
43+
this.floorNavData.activeIndex = this.swiper2.activeIndex
44+
// setCurrentSlide($(".swiper1 .swiper-slide").eq(n), n);
45+
// swiper1.slideTo(n, 500, false);
46+
}
47+
}
48+
}
49+
},
50+
computed: {
51+
swiper1 () {
52+
return this.$refs.swiper1.swiper
53+
},
54+
swiper2 () {
55+
return this.$refs.swiper2.swiper
56+
}
57+
},
58+
mounted () {
59+
// current swiper instance
60+
// 然后你就可以使用当前上下文内的swiper对象去做你想做的事了
61+
console.log('this is current swiper instance object', this.swiper1)
62+
console.log('this is current swiper instance object', this.swiper2)
63+
this.swiper2.slideTo(3, 1000, false)
64+
},
65+
methods: {
66+
onFloorNav (index) {
67+
this.floorNavData.activeIndex = index
68+
}
69+
}
70+
}
71+
</script>
72+
<style>
73+
.auto-width {
74+
width: auto!important;
75+
}
76+
.is-active {
77+
border-bottom: 1px solid red;
78+
}
79+
</style>

src/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
import Vue from 'vue'
44
import App from './App'
55
import router from './router'
6-
6+
import MintUI from 'mint-ui'
7+
import 'mint-ui/lib/style.css'
8+
import VueAwesomeSwiper from 'vue-awesome-swiper'
9+
import 'swiper/dist/css/swiper.css'
710
import './config/rem'
811
import FastClick from 'fastclick'
912
if ('addEventListener' in document) {
1013
document.addEventListener('DOMContentLoaded', function () {
1114
FastClick.attach(document.body)
1215
}, false)
1316
}
14-
17+
Vue.use(MintUI)
18+
Vue.use(VueAwesomeSwiper)
1519
Vue.config.productionTip = false // 生产环境去掉vue的警告信息
1620
/* eslint-disable no-new */
1721
new Vue({

src/page/home/home.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
<template>
2-
<div>home</div>
2+
<div>home
3+
<div>
4+
<button @click="goTest">效果测试页</button>
5+
</div>
6+
</div>
37
</template>
8+
<script>
9+
export default {
10+
data () {
11+
return {}
12+
},
13+
methods: {
14+
goTest () {
15+
this.$router.push('./test')
16+
}
17+
}
18+
}
19+
</script>

src/plugins/swiper.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/router/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const questionDetail = () => import('../page/service/children/questionDetail')
4949
const find = () => import('../page/find/find')
5050
const download = () => import('../page/download/download')
5151
const notFound = () => import('../components/common/404.vue')
52+
const test = () => import('../components/common/test.vue')
5253
const notAllow = () => import('../components/common/401.vue')
5354

5455
Vue.use(Router)
@@ -268,6 +269,10 @@ const router = new Router({
268269
component: pointsDetail
269270
}]
270271
},
272+
{
273+
path: 'test',
274+
component: test
275+
},
271276
{
272277
path: '401',
273278
component: notAllow

src/style/index.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@import './common.scss'; // reset 和 公共的css
22
@import './mixin.scss'; // 混合宏
3-
@import './home.scss'; // 首页
3+
@import './home.scss'; // 首页
4+
@import './test.scss'; // 测试页

src/style/test.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)