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

 达达2502854565 发布于 2022-11-08 16:44

小程序上面,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>
    2022-11-12 11:00 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有