首先还是按照常规的来 引入Vue.js和Swiper.js以及Swiper.css
直接上代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="js/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="css/swiper.min.css"/>
</head>
<body>
<div id="All">
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">slider1</div>
<div class="swiper-slide">slider2</div>
<div class="swiper-slide">slider3</div>
</div>
</div>
</div>
<script type="text/javascript">
new Vue({
el:"#All",
data(){
return{
a:[1,2,3]
}
},
methods:{
}
})
var mySwiper = new Swiper('.swiper-container', {
pagination: {
el: '.swiper-pagination',
clickable :true,
},
autoplay: true,//可选选项,自动滑动
loop : true,
delay: 3000,
})
</script>
</body>
</html>
过程中遇到一点小困难就是我一开始swiper实例在vue实例之前
也就是
<script type="text/javascript">
var mySwiper = new Swiper('.swiper-container', {
pagination: {
el: '.swiper-pagination',
clickable :true,
},
autoplay: true,//可选选项,自动滑动
loop : true,
delay: 3000,
})
new Vue({
el:"#All",
data(){
return{
a:[1,2,3]
}
},
methods:{
}
})
</script>
这样的,然后就跑不起来。
我也不知道为什么放到下面就可以跑起来,有没有知道的大佬指点一下
—————————————————————
小白上路,请多指教!!