mui的轮播图,如果图片是请求来的,直接在html中循环是不会动的。

需要请求完图片之后,在setTimeout方法里,使用slider()方法,这样才会动

而且mui的轮播图,有点坑的,需要重复最后一张和第一张,才会无缝链接

<template>
<div class="rotation">
<div class="logo"></div>
<div class="mui-slider">
<!-- mui-slider-loop 这个类是控制循坏轮播的 -->
<div class="mui-slider-group mui-slider-loop">
<!-- 重复最后一张轮播图 -->
<div class="mui-slider-item mui-slider-item-duplicate">
<img :src="last">
</div> <!-- 全部轮播图 -->
<div class="mui-slider-item" v-for="(item,i) in rotations">
<img :src="item.mpSlug" alt>
</div> <!-- 重复第一张轮播图 -->
<div class="mui-slider-item mui-slider-item-duplicate">
<img :src="first">
</div>
</div> <!-- 轮播图小圆点 -->
<div class="mui-slider-indicator">
<div class="mui-indicator" v-for="(item,i) in rotations"></div>
</div>
</div>
</div>
</template>
import { httpUrl } from "../../http/http.js";
export default {
name: "Rotation",
data() {
return {
rotations: [],
first: "",
last: ""
};
},
methods: {
getRotation() {
var data = "type=main_info&" + "offset=0&" + "limit=-1";
this.$axios.post(httpUrl.getContentsList, data).then(res => {
console.log(res);
this.rotations = res.data.rows;
//第一张
this.first = this.rotations[0].mpSlug;
//最后一张
this.last = this.rotations[this.rotations.length - 1].mpSlug;
});
}
},
created() {
this.getRotation();
//请求完成后再调用slider方法,由于axios里没有同步,所以使用setTimeout
setTimeout(function() {
//获得slider插件对象
var gallery = mui(".mui-slider");
gallery.slider({
interval: 3000 //自动轮播周期,若为0则不自动播放,默认为0;
});
}, 300);
}
};

vue+mui轮播图的更多相关文章

  1. mui轮播图为什么设置了自动播放参数也不能自动播放呢?

    最近在做项目的时候,发现Mui的轮播图遇到个问题,设置了自动播放但是怎么也不能自动播放,这是为什么呢? 原来如果动态给mui的图片轮播添加图片,又使用的ajax获取的数据,但是你ajax 还没有执行完 ...

  2. vue自定义轮播图组件 swiper

    1.banner 组件 components/Banner.vue <!-- 轮播图 组件 --> <template> <div class="swiper- ...

  3. mui轮播图

    轮播组件是mui提供的一个核心组件,在该核心组件基础上,衍生出了图片轮播.可拖动式图文表格.可拖动式选项卡.左右滑动9宫格等组件,这些组件有较多共同点.Dom构造: <div class=&qu ...

  4. vue项目轮播图的实现

    利用   Vue-Awesome-Swiper插件来做轮播效果,github地址:https://github.com/surmon-china/vue-awesome-swiper 安装 npm i ...

  5. vue简易轮播图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 两个页面实现mui轮播图与选项卡结合

    index.html页面 <!DOCTYPE html><html><head> <meta charset="utf-8"> &l ...

  7. vue中轮播图的实现

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. vue实现轮播图

    /* Start  基本样式*/ * {   margin: 0;   padding: 0; } ul {   list-style-type: none; } body {   font-size ...

  9. vue编写轮播图组件

    <template>  <div id="slider">    <div class="window" @mouseover=& ...

随机推荐

  1. 修改bootstrap-table中的分页样式

    使用bootstrap-table时,使用$("")选择器没办法选中下方的分页button按钮,可能跟它是动态生成的有关吧. 最终找到与之对应的js(bootstrap-table ...

  2. HDU 1542 Atlantis(线段树面积并)

     描述 There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. S ...

  3. django的request介绍和APIView流程分析和CBV的流程分析

    首先get请求的数据都在request.GET中,request.body中没有,因为只有post请求有请求体,request.body中的数据是请求体的数据 首先,我们还是用cbv的方式来讲解 我们 ...

  4. 数据库存储 datetime,时差问题

    var offset = moment().utcOffset(); var localText = moment.utc(datetime from database).utcOffset(offs ...

  5. C语言可以开发哪些项目?(转)

    原文地址:https://www.cnblogs.com/shiyanlou/p/6098661.html 知乎:https://www.zhihu.com/question/20564904 C语言 ...

  6. Android Studio 运行shell

    public void RunCmd(String mycmd) { Process su = null; try { su = Runtime.getRuntime().exec("su& ...

  7. js中用变量作为$()内id的值、动态获取id,及获取其下面的class元素

    在开发中写了一个公共方法对模板tpl进行渲染,然而他的id是通过变量传值过来的,在网上查阅后找到解决方法,写法如下: $("#"+tplVal).html(html); 用$(&q ...

  8. JFinal Web开发学习(九)后台添加前台显示博客

    效果: 发博客: 显示博客: 后台:使用hui-admin,文章编辑器是百度开源的ueditor 前台:使用layui前端框架 1.写控制器BlogController controller包中 pa ...

  9. xml转化为Dictionary

    代码 public SortedDictionary<string, object> FromXml(string xml) { SortedDictionary<string, o ...

  10. node.js下载安装

    1.下载node.js在node中文网站,官方网站下载太慢 2.接着让我们点击下载链接,页面上呈现出你所需要下载的安装包,我们这里选择windows x64的安装包进行下载 3.安装node.js,一 ...