欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序?qū)崿F(xiàn)多行文字滾動(dòng)效果

 更新時(shí)間:2022年03月03日 12:05:37   作者:Archer_yy  
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)多行文字滾動(dòng)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)多行文字滾動(dòng)的具體代碼,供大家參考,具體內(nèi)容如下

wxml

<view class="full" style="height:100%;overflow:hidden">
   <swiper autoplay="true" interval="3000" duration="500" circular="true" vertical="true" style="height:100%">
    <swiper-item wx:for="{{topnewslist}}" wx:key="{{index}}" catchtouchmove='catchTouchMove'>
     <van-notice-bar scrollable="{{false}}" bindtap="tonewsdetail" wx:for="{{item}}" wx:for-item="it" wx:key="{{index}}" data-newsid="{{it.new_id}}" style="width:100%" text="{{it.new_topic}}" />
    </swiper-item>
   </swiper>
</view>

wxss

swiper-item {
 height: 100%;
}

js

//index.js
//獲取應(yīng)用實(shí)例
import api from "../../utils/api.js"
var token = ''
const app = getApp()

Page({
 data: {
  topnewslist:[]
 },
 onLoad: function () {
 },
 tonewsdetail(e){
  var newsid=e.currentTarget.dataset.newsid;
  wx.navigateTo({
   url: '/pages/newsdetail/newsdetail?newsid='+newsid,
  })
 },

 loadscrollnews(){
  api.get("mpapi/mpmnews.ashx", { action:'toplist',token:token}).then((res)=>{
   if(res.code==1){
   //res.list=[{"new_id":1,"new_topic":"111"},{"new_id":2,"new_topic":"222"},{"new_id":3,"new_topic":"333"},{"new_id":4,"new_topic":"444"}]
    this.setData({
     topnewslist: this.splitArr(res.list, 2) //調(diào)用
     //調(diào)用之后[[{"new_id":1,"new_topic":"111"},{"new_id":2,"new_topic":"222"}],[{"new_id":3,"new_topic":"333"},{"new_id":4,"new_topic":"444"}]]
    })
   }
  })
 },
 /**
  * 分割數(shù)組創(chuàng)建二維數(shù)組封裝
  * @param data 數(shù)組
  * @param senArrLen 需要分割成子數(shù)組的長(zhǎng)度
  */
 splitArr(data, senArrLen){
  //處理成len個(gè)一組的數(shù)據(jù)
  let data_len = data.length;
  let arrOuter_len = data_len % senArrLen === 0 ? data_len / senArrLen : parseInt((data_len / senArrLen) + '') + 1;
  let arrSec_len = data_len > senArrLen ? senArrLen : data_len;//內(nèi)層數(shù)組的長(zhǎng)度
  let arrOuter = new Array(arrOuter_len);//最外層數(shù)組
  let arrOuter_index = 0;//外層數(shù)組的子元素下標(biāo)
  // console.log(data_len % len);
  for (let i = 0; i < data_len; i++) {
   if (i % senArrLen === 0) {
    arrOuter_index++;
    let len = arrSec_len * arrOuter_index;
    //將內(nèi)層數(shù)組的長(zhǎng)度最小取決于數(shù)據(jù)長(zhǎng)度對(duì)len取余,平時(shí)最內(nèi)層由下面賦值決定
    arrOuter[arrOuter_index - 1] = new Array(data_len % senArrLen);
    if (arrOuter_index === arrOuter_len)//最后一組
     data_len % senArrLen === 0 ?
      len = data_len % senArrLen + senArrLen * arrOuter_index :
      len = data_len % senArrLen + senArrLen * (arrOuter_index - 1);
    let arrSec_index = 0;//第二層數(shù)組的索引
    for (let k = i; k < len; k++) {//第一層數(shù)組的開(kāi)始取決于第二層數(shù)組長(zhǎng)度*當(dāng)前第一層的索引
     arrOuter[arrOuter_index - 1][arrSec_index] = data[k];
     arrSec_index++;
    }
   }
  }
  return arrOuter
 },
 // 截獲豎向滑動(dòng)
 catchTouchMove: function (res) {
  return false
 },
})

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • JavaScript簡(jiǎn)寫(xiě)技巧

    JavaScript簡(jiǎn)寫(xiě)技巧

    這篇文章主要介紹了JavaScript簡(jiǎn)寫(xiě)技巧,運(yùn)用簡(jiǎn)寫(xiě)技巧,可以加快開(kāi)發(fā)速度,讓開(kāi)發(fā)工作事半功倍,大家感興趣的話可以參考本篇文章
    2021-08-08
  • 一文詳解requestAnimationFrame請(qǐng)求動(dòng)畫(huà)幀

    一文詳解requestAnimationFrame請(qǐng)求動(dòng)畫(huà)幀

    requestAnimationFrame是一個(gè)用于動(dòng)畫(huà)效果的 API,它使用瀏覽器的刷新率來(lái)執(zhí)行回調(diào)函數(shù),通常每秒鐘執(zhí)行60次,這篇文章主要給大家介紹了關(guān)于requestAnimationFrame請(qǐng)求動(dòng)畫(huà)幀的相關(guān)資料,需要的朋友可以參考下
    2023-12-12
  • javascript實(shí)現(xiàn)簡(jiǎn)單的鼠標(biāo)拖動(dòng)效果實(shí)例

    javascript實(shí)現(xiàn)簡(jiǎn)單的鼠標(biāo)拖動(dòng)效果實(shí)例

    這篇文章主要介紹了javascript實(shí)現(xiàn)簡(jiǎn)單的鼠標(biāo)拖動(dòng)效果,實(shí)例分析了javascript鼠標(biāo)拖動(dòng)效果的相關(guān)要點(diǎn)與實(shí)現(xiàn)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-04-04
  • Js 控制表單域代碼

    Js 控制表單域代碼

    js改變下拉框的顯示等實(shí)現(xiàn)代碼。
    2009-05-05
  • 淺談JS中json數(shù)據(jù)的處理

    淺談JS中json數(shù)據(jù)的處理

    下面小編就為大家?guī)?lái)一篇淺談JS中json數(shù)據(jù)的處理。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-06-06
  • js 客戶端打印html 并且去掉頁(yè)眉、頁(yè)腳的實(shí)例

    js 客戶端打印html 并且去掉頁(yè)眉、頁(yè)腳的實(shí)例

    下面小編就為大家?guī)?lái)一篇js 客戶端打印html 并且去掉頁(yè)眉、頁(yè)腳的實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-11-11
  • 微信小程序點(diǎn)擊保存圖片到本機(jī)功能

    微信小程序點(diǎn)擊保存圖片到本機(jī)功能

    這篇文章主要介紹了微信小程序點(diǎn)擊保存圖片到本機(jī)功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-12-12
  • JavaScript數(shù)據(jù)類型檢測(cè)實(shí)現(xiàn)方法詳解

    JavaScript數(shù)據(jù)類型檢測(cè)實(shí)現(xiàn)方法詳解

    Javascript中檢查數(shù)據(jù)類型一直是老生常談的問(wèn)題,類型判斷在web開(kāi)發(fā)中也有著非常廣泛的應(yīng)用,所以下面這篇文章主要給大家介紹了關(guān)于JS數(shù)據(jù)類型檢測(cè)的那些事,需要的朋友可以參考下
    2022-11-11
  • js針對(duì)ip地址、子網(wǎng)掩碼、網(wǎng)關(guān)的邏輯性判斷

    js針對(duì)ip地址、子網(wǎng)掩碼、網(wǎng)關(guān)的邏輯性判斷

    這篇文章主要介紹了js針對(duì)ip地址、子網(wǎng)掩碼、網(wǎng)關(guān)的邏輯性判斷,感興趣的小伙伴們可以參考一下
    2016-01-01
  • JS實(shí)現(xiàn)京東商品分類側(cè)邊欄

    JS實(shí)現(xiàn)京東商品分類側(cè)邊欄

    這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)京東商品分類側(cè)邊欄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-12-12

最新評(píng)論