小程序上面,swiper作为一个页面,然后其他页面调用的时候,貌似老是掉不出来。
include 和 import 都不行。
可以了,swiper在调用的时候,1,自己可以做一个模板,然后其他页面调用这个。给数据就行。2,可以直接写入。
index.wxml:
<import src="../swiper/swiper.wxml"/> <template is="b" data="{{...imgScroll}}"></template>
index.js:
Page({ data: { motto: 'Hello World', flag:true, item:{ date:'2016.09.08', time:'08:08:04', msg:'hello', condition:true, buxianshi:false }, userInfo: {}, src:'http://img.yonghejinrong.com/news/4v/jh/j2/vy5mskswwoo8w4sk00g.jpg', imgScroll:{ imgUrls: [ 'http://img.yonghejinrong.com/news/ce/2y/jz/j75xc0ok0wkggksog8k.jpg', 'http://img.yonghejinrong.com/news/2m/p7/gb/7hfew40cok40s000ks0.jpg', 'http://img.yonghejinrong.com/news/4v/jh/j2/vy5mskswwoo8w4sk00g.jpg' ], indicatorDots: true, autoplay: true, interval: 5000, duration: 1000 } } })
swiper.wxml:
<template name="b"> <swiper id="swiper" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <block wx:for="{{imgUrls}}"> <swiper-item> <image src="{{item}}" class="slide-image" /> </swiper-item> </block> </swiper> </template>