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

微信小程序?qū)崿F(xiàn)選擇內(nèi)容顯示對應(yīng)內(nèi)容

 更新時(shí)間:2022年07月19日 16:52:02   作者:山橘滿月  
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)選擇內(nèi)容顯示對應(yīng)內(nèi)容,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

微信小程序中,經(jīng)??梢娺x擇地區(qū)或者商品分類或者其他的分類,選擇后顯示,選擇后刪除

先介紹一下主要功能:點(diǎn)擊 ‘地區(qū)’ ,下面選擇區(qū)域出現(xiàn),點(diǎn)擊 ‘選擇地區(qū)’ 中的按鈕,上面 ‘已選地區(qū)’ 顯示選擇的地區(qū),點(diǎn)擊 ‘x’ 已選的地區(qū)就取消,點(diǎn)擊 “完成” 整個(gè)選擇區(qū)域隱藏,只留下地區(qū)。

整體樣式用的彈性布局,就不細(xì)說了。

wxml:

<view class="container">
? <text bindtap="show" class="color">地區(qū)</text>
? <view class="choose" wx-if="{{a}}">
? ? <!-- 已選地區(qū) -->
? ? <view class="chosed">
? ? ? <view class="chosedtop">
? ? ? ? <text>已選地區(qū)</text>
? ? ? ? <text bindtap="finish">完成</text>
? ? ? </view>
? ? ? <view class="view">
? ? ? ? <view class="position" wx:for='{{area}}' wx:key='index'>
? ? ? ? ? <button class="buttond">{{item}}</button>
? ? ? ? ? <image src='' bindtap="shut" data-index="{{index}}" data-name="{{item}}"></image>
? ? ? ? ? //這是按鈕右上角的關(guān)閉圖片
? ? ? ? </view>
? ? ? </view>
? ? </view>
? ? <!-- 選擇地區(qū) -->
? ? <view class="area">
? ? ? <text>選擇地區(qū)</text>
? ? ? <view class="chos">
? ? ? ? <block wx:for='{{array}}' wx:key='index'>
? ? ? ? ? <button class="button {{tabindex == index?'active':''}}" data-index="{{index}}" data-name="{{item}}" bindtap="tabarea">{{item}}</button>
? ? ? ? </block>
? ? ? </view>
? ? </view>
? </view>
</view>

 js:

var chosedarea = [];
var area = [];
Page({?
? data: {
? ? a:false,
? ? tabindex:0,
? ? array: ["北京", '南京', '上海', '天津', '杭州', '云南', "北京", '南京', '上海', '天津', '杭州', '云南',"北京", '南京', '上海', '天津', '杭州', '云南'],
? },
? // 選地區(qū)
? ?tabarea:function(e){
? ? this.setData({
? ? ? tabindex:e.currentTarget.dataset.index
? ? });
? ? ?var id = e.currentTarget.dataset.index;
? ? ?var name = e.currentTarget.dataset.name;
? ? ?chosedarea.push(name);
? ? ? ?this.setData({
? ? ? ? ?"area": chosedarea
? ? ? ?})
? },
? // 取消已選地區(qū)
? shut:function(e){
? ? this.setData({
? ? ? index: e.currentTarget.dataset.index,
? ? ? name : e.currentTarget.dataset.name
? ? });
? ? var yid = e.currentTarget.dataset.index;
? ? var yname = e.currentTarget.dataset.name;
? ? chosedarea.splice(yid,1)
? ? this.setData({
? ? ? "area": chosedarea
? ? })
? },
? // 點(diǎn)擊完成隱藏
? finish:function(){
? ? var that = this;
? ? if (that.data.a == true) {
? ? ? that.setData({
? ? ? ? a: false ??
? ? ? })
? ? }
? },
? // 點(diǎn)擊地區(qū)顯示
? show:function(){
? ? var that = this;
? ? if (that.data.a == false) {
? ? ? that.setData({
? ? ? ? a: true ? ?
? ? ? })
? ? }
? },
? })

css

.container{
? width: 100%;
? height: 300rpx;
}
.choose{
? width: 100%;
}
.buttond{
? width: 88%;
? padding: 0;
? height: 68rpx;
? line-height: 68rpx;
? font-size: 32rpx;
? margin-bottom: 10rpx;
}
.area{
? display: flex;
? flex-direction: column;
? margin: 0 20rpx;
}
.chos{
? display: flex;
? flex-wrap: wrap;
? margin-top: 15rpx;
}
.button{
? width: 22%;
? padding: 0;
? height: 68rpx;
? line-height: 68rpx;
? font-size: 32rpx;
? margin: 0 10rpx;
? margin-bottom: 10rpx;
}
.view{
? display: flex;
? flex-wrap: wrap;
? height: auto;
? margin: 0 20rpx;
}
.position{
? width: 24%;
}
.chosedtop{
? display: flex;
? justify-content: space-between;
? margin: 0 30rpx 15rpx
}

如果是選完 上面添加了對應(yīng)的 下面可選擇的與之對應(yīng)的要隱藏掉 就這樣: 

 js中

// 選地區(qū)
? tabarea: function (e) {
? ? let that = this;
? ? that.setData({
? ? ? tabindex: e.currentTarget.dataset.index
? ? });
? ? var id = e.currentTarget.dataset.index;
? ? var name = e.currentTarget.dataset.name;
? ? chosedarea.push(name);
? ? that.data.array.splice(id, 1);
? ? that.setData({
? ? ? "area": chosedarea,
? ? ? "array": that.data.array
? ? })
? },

在上面點(diǎn)擊刪除的話 下面可選擇的區(qū)域要對應(yīng)的添加上:

wxml:

<view class="container">
? <text bindtap="show" class="color">地區(qū)</text>
? <view class="choose" wx-if="{{a}}">
? ? <!-- 已選地區(qū) -->
? ? <view class="chosed">
? ? ? <view class="chosedtop">
? ? ? ? <text>已選地區(qū)</text>
? ? ? ? <text bindtap="finish">完成</text>
? ? ? </view>
? ? ? <view class="view">
? ? ? ? <view class="position" wx:for='{{area}}' wx:key='index'>
? ? ? ? ? <button class="buttond" data-index="{{index}}" data-name="{{item}}" bindtap="addName">{{item}}</button>
? ? ? ? ? <!-- <image src='' bindtap="shut" data-index="{{index}}" data-name="{{item}}"></image> -->
? ? ? ? ? <!-- //這是按鈕右上角的關(guān)閉圖片 -->
? ? ? ? </view>
? ? ? </view>
? ? </view>
? ? <!-- 選擇地區(qū) -->
? ? <view class="area">
? ? ? <text>選擇地區(qū)</text>
? ? ? <view class="chos">
? ? ? ? <block wx:for='{{array}}' wx:key='index'>
? ? ? ? ? <button class="button {{tabindex == index?'active':''}}" data-index="{{index}}" data-name="{{item}}" bindtap="tabarea">{{item}}</button>
? ? ? ? </block>
? ? ? </view>
? ? </view>
? </view>
</view>

js

var chosedarea = [];
var area = [];
Page({
? data: {
? ? a: false,
? ? tabindex: 0,
? ? array: ["北京", '南京', '上海', '天津', '杭州', '云南', "新疆", '黑龍江', '東北', '威海', '寧夏', '廣西', "西安", '山東', '青島', '濟(jì)南', '煙臺(tái)', '蓬萊'],
? },
? // 選地區(qū)
? tabarea: function (e) {
? ? let that = this;
? ? that.setData({
? ? ? tabindex: e.currentTarget.dataset.index
? ? });
? ? var id = e.currentTarget.dataset.index;
? ? var name = e.currentTarget.dataset.name;
? ? chosedarea.push(name);
? ? that.data.array.splice(id, 1);
? ? that.setData({
? ? ? "area": chosedarea,
? ? ? "array": that.data.array
? ? })
? },
? // 添加回
? addName:function(e){
? ? let that = this;
? ? console.log(e)
? ? that.setData({
? ? ? index: e.currentTarget.dataset.index,
? ? })
? ? var aname = e.currentTarget.dataset.name;
? ? chosedarea.splice(that.data.index,1);
? ? that.data.array.push(aname);
? ? that.setData({
? ? ? "area": chosedarea,
? ? ? "array": that.data.array
? ? })
? },
? // 取消已選地區(qū)
? shut: function (e) {
? ? this.setData({
? ? ? index: e.currentTarget.dataset.index,
? ? ? name: e.currentTarget.dataset.name
? ? });
? ? var yid = e.currentTarget.dataset.index;
? ? var yname = e.currentTarget.dataset.name;
? ? chosedarea.splice(yid, 1)
? ? this.setData({
? ? ? "area": chosedarea
? ? })
? },
? // 點(diǎn)擊完成隱藏
? finish: function () {
? ? var that = this;
? ? if (that.data.a == true) {
? ? ? that.setData({
? ? ? ? a: false
? ? ? })
? ? }
? },
? // 點(diǎn)擊地區(qū)顯示
? show: function () {
? ? var that = this;
? ? if (that.data.a == false) {
? ? ? that.setData({
? ? ? ? a: true
? ? ? })
? ? }
? },
})

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

相關(guān)文章

  • js實(shí)現(xiàn)class樣式的修改、添加及刪除的方法

    js實(shí)現(xiàn)class樣式的修改、添加及刪除的方法

    這篇文章主要介紹了js實(shí)現(xiàn)class樣式的修改、添加及刪除的方法,主要通過修改標(biāo)簽的className來實(shí)現(xiàn)這一功能,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-01-01
  • layui 地區(qū)三級聯(lián)動(dòng) form select 渲染的實(shí)例

    layui 地區(qū)三級聯(lián)動(dòng) form select 渲染的實(shí)例

    今天小編就為大家分享一篇layui 地區(qū)三級聯(lián)動(dòng) form select 渲染的實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-09-09
  • XML、HTML、CSS與JS的區(qū)別整理

    XML、HTML、CSS與JS的區(qū)別整理

    在BS中,xml,html,css和js我們都學(xué)過,起初分不清這四者的區(qū)別和聯(lián)系,隨著知識(shí)的增長,有了一些體會(huì),下面通過本文給大家簡單介紹 XML、HTML、CSS與JS的區(qū)別,需要的朋友參考下
    2016-02-02
  • 前端URL拼接路徑參數(shù)具體實(shí)現(xiàn)代碼

    前端URL拼接路徑參數(shù)具體實(shí)現(xiàn)代碼

    這篇文章主要給大家介紹了關(guān)于前端URL拼接路徑參數(shù)具體實(shí)現(xiàn)的相關(guān)資料,url地址拼接是經(jīng)常會(huì)遇到的問題,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-12-12
  • 用原生JS獲取CLASS對象(很簡單實(shí)用)

    用原生JS獲取CLASS對象(很簡單實(shí)用)

    這篇文章主要介紹了如何用原生JS獲取CLASS對象,看過dom編程藝術(shù)的朋友或許會(huì)知道的
    2014-10-10
  • HTML5附件拖拽上傳drop & google.gears實(shí)現(xiàn)代碼

    HTML5附件拖拽上傳drop & google.gears實(shí)現(xiàn)代碼

    從gmail 的附件拖拽上傳,到網(wǎng)易郵箱的拖拽上傳,我們看到了html 5 為我們帶來了新的web體驗(yàn)。
    2011-04-04
  • javascript Array對象使用小結(jié)

    javascript Array對象使用小結(jié)

    數(shù)組是一段線性分配的內(nèi)存,它通過整數(shù)去計(jì)算偏移并訪問其中的元素。數(shù)組是很快的數(shù)據(jù)結(jié)構(gòu),但不幸的是,Javascript并沒有像這種數(shù)組一樣的數(shù)據(jù)結(jié)構(gòu)。
    2009-12-12
  • JavaScript獲得input元素value值的方法

    JavaScript獲得input元素value值的方法

    在頁面中我們最常見的頁面元素就是input了,但是我們?nèi)绾斡肑avaScript得到網(wǎng)頁input中輸入的value值呢,其實(shí)很簡單,方法也不止一種,今天給大家分享兩種JavaScript獲得input元素value值的方法,感興趣的朋友跟隨小編一起看看吧
    2023-10-10
  • 微信小程序?qū)崿F(xiàn)輪播圖指示器

    微信小程序?qū)崿F(xiàn)輪播圖指示器

    這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)輪播圖指示器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • js 實(shí)現(xiàn)菜單左右滾動(dòng)顯示示例介紹

    js 實(shí)現(xiàn)菜單左右滾動(dòng)顯示示例介紹

    菜單左右滾動(dòng)顯示的實(shí)現(xiàn)方法有很多,在本文將為大家介紹下如何使用js實(shí)現(xiàn),需要的朋友可以參考下,希望對大家有所幫助
    2013-11-11

最新評論