javascript - 小程序上面,swiper作为一个页面,然后其他页面调用的时候,貌似老是掉不出来。
黄舟
黄舟 2017-04-11 13:11:45
[JavaScript讨论组]

小程序上面,swiper作为一个页面,然后其他页面调用的时候,貌似老是掉不出来。
include 和 import 都不行。

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(1)
阿神

可以了,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>
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号