微信小程序的宿主環(huán)境實(shí)現(xiàn)代碼
??小程序的宿主環(huán)境 - 組件
1.scroll-view 組件的基本使用
實(shí)現(xiàn)如圖的縱向滾動(dòng)效果
<scroll-view class="container_2" scroll-y> <view>T</view> <view>S</view> <view>J</view> </scroll-view>
.container_2 view{ width: 100px; height: 100px; text-align: center; line-height: 100px; } .container_2 view:nth-child(1){ background-color: red; } .container_2 view:nth-child(2){ background-color: yellowgreen; } .container_2 view:nth-child(3){ background-color: blue; } .container_2{ display: flex; justify-content: space-around } .container_2{ border: 1px solid yellowgreen; height: 130px; width: 100px; }
scroll-y 改成 scroll-x
實(shí)現(xiàn)如圖的橫向滾動(dòng)效果:
<scroll-view class="container_2" scroll-x> <view>橫 向 滑 動(dòng) 演 示</view> </scroll-view>
.container_2 view{ width: 300px; height: 100px; text-align: center; line-height: 100px; } .container_2 view:nth-child(1){ background-color: red; } .container_2{ display: flex; justify-content: space-around } .container_2{ border: 1px solid yellowgreen; height: 100px; width: 100px; }
2.swiper 和 swiper-item 組件的基本使用
實(shí)現(xiàn)如圖的輪播圖效果:
<swiper class="container_3" indicator-dots> <swiper-item> <view class="item">1</view> </swiper-item> <swiper-item> <view class="item">2</view> </swiper-item> <swiper-item> <view class="item">3</view> </swiper-item> <swiper-item> <view class="item">4</view> </swiper-item> </swiper>
.container_3{ height: 160px; } .item{ height: 100%; line-height: 150px; text-align: center; } swiper-item:nth-child(1) .item{ background-color: burlywood; } swiper-item:nth-child(2) .item{ background-color: yellow; } swiper-item:nth-child(3) .item{ background-color: pink; } swiper-item:nth-child(4) .item{ background-color: aqua; }
.swiper 組件的常用屬性
屬性 | 類型 | 默認(rèn)值 | 說明 |
indicator-dots | boolean | false | 是否顯示面板指示點(diǎn) |
indicator-color | color | rgba(0, 0, 0, .3) | 指示點(diǎn)顏色 |
indicator-active-color | color | #000000 | 當(dāng)前選中的指示點(diǎn)顏色 |
autoplay | boolean | false | 是否自動(dòng)切換 |
interval | number | 5000 | 自動(dòng)切換時(shí)間間隔 |
circular | boolean | false | 是否采用銜接滑動(dòng) |
3.text 組件的基本使用
文本組件
類似于 HTML 中的 span 標(biāo)簽,是一個(gè)行內(nèi)元素
通過 text 組件的 selectable 屬性,實(shí)現(xiàn)長(zhǎng)按選中文本內(nèi)容的效果:
<view> 手機(jī)號(hào): <text selectable>17608777</text> </view>
4.rich-text 組件的基本使用
富文本組件
支持把 HTML 字符串渲染為 WXML 結(jié)構(gòu)
<rich-text nodes="<h1 style='color:pink;'>一級(jí)標(biāo)題 <h1>"></rich-text>
到此這篇關(guān)于微信小程序的宿主環(huán)境的文章就介紹到這了,更多相關(guān)小程序宿主環(huán)境內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
JavaScript中 ?、!和?? 的用法及區(qū)別詳解
在JavaScript中,?., !., 和 ?? 是三個(gè)不同的操作符,各自有不同的用途,旨在提高代碼的簡(jiǎn)潔性和安全性,尤其是在處理可能的null或undefined值時(shí),下面分別解釋這三個(gè)操作符的用法,需要的朋友可以參考下2024-10-10JS 實(shí)現(xiàn)獲取驗(yàn)證碼 倒計(jì)時(shí)功能
這篇文章主要介紹了JS 實(shí)現(xiàn)獲取驗(yàn)證碼 倒計(jì)時(shí)功能,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-10-10微信小程序獲取微信運(yùn)動(dòng)步數(shù)的實(shí)例代碼
本篇文章主要介紹了微信小程序微信運(yùn)動(dòng)步數(shù)的實(shí)例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07js簡(jiǎn)單判斷移動(dòng)端系統(tǒng)的方法
這篇文章主要介紹了js簡(jiǎn)單判斷移動(dòng)端系統(tǒng)的方法,通過JavaScript的navigator.userAgent相關(guān)屬性判斷訪問端的系統(tǒng)類型,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2016-02-02使用JavaScript開發(fā)IE瀏覽器本地插件實(shí)例
這篇文章主要介紹了使用JavaScript開發(fā)IE瀏覽器本地插件實(shí)例,本文講解使用JS+注冊(cè)表的方式開發(fā)一個(gè)IE瀏覽器本地插件,需要的朋友可以參考下2015-02-02一文詳解JS中的Map、Set、WeakMap和WeakSet
在JavaScript中,Map、Set、WeakMap和WeakSet是四個(gè)不同的數(shù)據(jù)結(jié)構(gòu),它們都有不同的特點(diǎn)和用途,本文詳細(xì)介紹了Map、Set、WeakMap和WeakSet的用法及區(qū)別,需要的朋友可以參考下2023-04-04原生js實(shí)現(xiàn)class的添加和刪除簡(jiǎn)單代碼
下面小編就為大家?guī)硪黄鷍s實(shí)現(xiàn)class的添加和刪除簡(jiǎn)單代碼。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-07-07