当前位置: 首页 > news >正文

设计专业干货推荐网站搜索引擎优化论文

设计专业干货推荐网站,搜索引擎优化论文,龙海网站建设价格,网站推广套餐一、自定义轮播图组件、自动注册 以首页轮播图组件为例。 1、创建组件文件src/components/my-swipper.vue 代码如下&#xff1a; <template><view><view class"uni-margin-wrap"><swiper class"swiper" circular :indicator-dots…

一、自定义轮播图组件、自动注册

以首页轮播图组件为例。

1、创建组件文件src/components/my-swipper.vue

代码如下:

<template><view><view class="uni-margin-wrap"><swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval":duration="duration"><swiper-item><view class="swiper-item uni-bg-red">A</view></swiper-item><swiper-item><view class="swiper-item uni-bg-green">B</view></swiper-item><swiper-item><view class="swiper-item uni-bg-blue">C</view></swiper-item></swiper></view></view>
</template><script lang="ts">
export default {data() {return {background: ['color1', 'color2', 'color3'],indicatorDots: true,autoplay: true,interval: 2000,duration: 500}},methods: {changeIndicatorDots(e) {this.indicatorDots = !this.indicatorDots},changeAutoplay(e) {this.autoplay = !this.autoplay},intervalChange(e) {this.interval = e.target.value},durationChange(e) {this.duration = e.target.value}}
}
</script><style>.uni-margin-wrap {width: 690rpx;width: 100%;}.swiper {height: 300rpx;}.swiper-item {display: block;height: 300rpx;line-height: 300rpx;text-align: center;color: white;}.uni-bg-red{background-color: red;}.uni-bg-green{background-color: green;}.uni-bg-blue{background-color: blue;}
</style>

2、在pages.json中配置自动注册,添加配置代码"^my-(.*)": "@/components/my-$1.vue"

{"easycom": {"autoscan": true,"custom": {// uni-ui 规则如下配置"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue",// 自定义组件,配置自动导入"^my-(.*)": "@/components/my-$1.vue"}},// ... //	
}

3、在页面中直接使用<my-navbar/>

不用再手动import

<template><my-navbar/><view class="content"><image mode="aspectFill" class="logo" src="/static/logo.png" /><view class="text-area"><text class="title">{{ title }}</text></view></view>
</template>

4、配置ts类型提示

在组件目录components创建文件components.d.ts,内容如下,

import MySwipper from "./my-swipper.vue";
declare module '@vue/runtime-core' {export interface GlobalComponents {MySwipper: typeof MySwipper,}
}

在这里插入图片描述

二、增加轮播图指示点组件

uni-swiper-dot组件在swiper 基础上面增加了丰富的指示点样式。

UniHelper为我们提供了各种组件的类型声明,可以直接使用。如下面change事件中的ev参数 ev: UniHelper.SwiperOnChangeEvent

使用轮播图指示点组件需要把swiper组件的默认指示点(indicator-dots)设置为false,否则会出现两层指示点。

核心参数

  • mode:指示点的类型,可选值:default 、round 、nav 、 indexes
  • current:当前指示点索引,必须是通过 swiper 的 change 事件获取到的 e.detail.current
  • dotsStyles:指示点样式
  • info:轮播图的数据,通过数组长度决定指示点个数
  • field:mode 为 nav 时,显示的内容字段(mode = nav 时必填)
<template><view><view class="uni-margin-wrap"><uni-swiper-dot class="uni-swiper-dot-box" @clickItem=clickItem :info="info" :current="current" :mode="mode":dots-styles="dotsStyles" field="content"><swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval":current="swiperDotIndex" :duration="duration" @change="onchange"><swiper-item v-for="(item, index) in info"><view :class="'swiper-item ' + item.colorClass">{{ item.content }}</view></swiper-item></swiper></uni-swiper-dot></view></view>
</template>
<script lang="ts">
export default {data() {return {indicatorDots: false,autoplay: true,interval: 2000,duration: 500,info: [{colorClass: 'uni-bg-red',content: '内容 A'},{colorClass: 'uni-bg-green',content: '内容 B'},{colorClass: 'uni-bg-blue',content: '内容 C'}],modeIndex: -1,styleIndex: -1,current: 0,mode: 'default',//default, dot, round, nav, indexesdotsStyles: {backgroundColor: 'rgba(83, 200, 249,0.3)',border: '1px rgba(83, 200, 249,0.3) solid',color: '#fff',selectedBackgroundColor: 'rgba(83, 200, 249,0.9)',selectedBorder: '1px rgba(83, 200, 249,0.9) solid'},swiperDotIndex: 0}},methods: {onchange(ev: UniHelper.SwiperOnChangeEvent) {this.current = ev.detail.current},clickItem(e: number) {this.swiperDotIndex = e}}
}
</script>

在这里插入图片描述

参考

  • https://uniapp.dcloud.net.cn/component/uniui/uni-swiper-dot.html
http://www.hkea.cn/news/993577/

相关文章:

  • 做网站遇到的困难总结网络营销软件代理
  • 做网站登录论坛外链代发
  • 东营专业网站建设公司排行青岛谷歌优化公司
  • 公众号和网站先做哪个口碑营销的形式
  • 长沙企业建网站费用关键词搜索推广排行榜
  • 怎么做网站端口代理沧州网络推广外包公司
  • php wordpress 目录seo课程培训机构
  • 常州网站建设方案优化引流app推广软件
  • 网络营销网站建设实训网络营销步骤
  • 网站都有后台吗百度竞价开户公司
  • 秭归网站建设网站seo优化心得
  • wordpress电影网站模板seo运营
  • 公司注册网上核名业务如何终止网站排名优化怎么做
  • 网站建设伍金手指下拉2网上推广平台
  • 沧州网站建设公司翼马爱情链接
  • 计算机学了出来干嘛免费优化推广网站的软件
  • 宁波网站建设优化湖南seo优化按天付费
  • 门户网站手机版google官网入口
  • 深圳市工程建设交易服务中心网站软文什么意思
  • 大型网架加工厂成都网站建设方案优化
  • 导航网站的广告怎么做的千锋教育官方网
  • etc网站开发票网站制作软件免费下载
  • 上海seo网站设计2022十大网络营销案例
  • 还有做网站的必要吗网站运营推广方案
  • 企业营销型网站建设厂家品牌搜索引擎服务优化
  • 学校网站建设计划怎么成为百度推广代理商
  • 普陀网站开发培训学校seo快速优化
  • 建一个商城网站多少钱免费的网站推广软件
  • 手机网站解决方案看网站搜什么关键词
  • 顺企网江西网站建设宜昌今日头条新闻