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

上海高端网页设计南宁seo怎么做优化团队

上海高端网页设计,南宁seo怎么做优化团队,多用户电商平台,河南政务服务网省市区三级联动选择是个很频繁的需求,但是查看了市面上很多插件不是太老不维护就是不满足需求,就试着实现一个 这个功能无任何依赖插件 功能略简单,但能实现需求 核心代码也尽力控制在了60行左右 pca-code.json树型数据来源 Administrative-d…

在这里插入图片描述
省市区三级联动选择是个很频繁的需求,但是查看了市面上很多插件不是太老不维护就是不满足需求,就试着实现一个
这个功能无任何依赖插件
功能略简单,但能实现需求
核心代码也尽力控制在了60行左右
pca-code.json树型数据来源 Administrative-divisions-of-China
下面只贴了省市区选择的功能,全部代码可参考github area分支

import { useState, useEffect } from 'react'
import { View, StyleSheet, FlatList, Text, TouchableOpacity } from 'react-native'
import pcaCode from "../assets/pca-code.json"export default () => {const [selected, setSelected] = useState([]) //选择过的省市区const [options, setOptions] = useState([pcaCode]) //每一级的数据const [level, setLevel] = useState(0) // 当前展示第几级useEffect(() => {console.log(selected)}, [selected])const renderItem = ({ item }) => (<TouchableOpacity style={styles.option} onPress={() => activeItem(item)}><Text style={[styles.option_text, isActive(item.code) && styles.option_text_active]}>{item.name}</Text>{isActive(item.code) && <View style={styles.option_icon} />}</TouchableOpacity >)const isActive = (code) => selected.some(item => item.code == code)const activeItem = (item) => {setSelected((prev) => {const newSelected = [...prev]newSelected[level] = { code: item.code, name: item.name }return newSelected.slice(0, level + 1)})if (level < 2) {const nextLevel = level + 1setLevel(nextLevel)setOptions((prev) => {const nextOptions = [...prev]nextOptions[nextLevel] = item.childrenreturn nextOptions})}}const PanelTab = () => {const tabs = selected.length < 3 ? selected.concat({ name: "请选择" }) : selectedreturn (<View style={styles.tab}>{tabs.map((item, index) => {return (<View style={styles.tab_item} key={index}><TouchableOpacity onPress={() => setLevel(index)}><Text style={item.code ? styles.tab_item_text : styles.tab_item_text_gray}>{item.name}</Text></TouchableOpacity>{level == index && <View style={styles.tab_item_line} />}</View>)})}</View>)}return (<><PanelTab /><FlatList style={styles.flat} data={options[level]} renderItem={renderItem} keyExtractor={item => item.code} /></>)
}const styles = StyleSheet.create({flat: {height: 500,},option: {height: 40,paddingRight: 15,flexDirection: "row",alignItems: "center",justifyContent: "space-between",},option_text: {fontSize: 14},option_text_active: {color: "#409eff",fontWeight: 'bold',},option_icon: {width: 6,height: 10,borderBottomWidth: 2,borderBottomColor: "#409eff",borderRightWidth: 2,borderRightColor: "#409eff",transform: "rotate(45deg)"},tab: {flexDirection: "row",marginBottom: 10,},tab_item: {position: "relative",marginRight: 15,},tab_item_text: {fontSize: 14,fontWeight: 'bold',paddingBottom: 10,},tab_item_text_gray: {fontSize: 14,color: "gray",paddingBottom: 10,},tab_item_line: {position: "absolute",bottom: 0,left: 0,width: "100%",height: 3,borderRadius: 5,backgroundColor: "#409eff"}
})
http://www.ritt.cn/news/28249.html

相关文章:

  • 包头网站设计公司无锡seo关键词排名
  • 做58同城网站可靠么开通网站需要多少钱
  • 泰安集团网站建设武汉seo关键词排名
  • xampp可以做网站吗百度推广官网入口
  • 免费建设手机网站网站seo推广优化
  • 网站数据库安装教程最新全国疫情实时大数据
  • discuz 分类网站什么是软文营销
  • 网站开发 方案百度一下官网入口
  • 怎样看是静态网站还是动态网站 怎么操作如何去做网络推广
  • 做网站与网页有什么区别网站开发月薪多少钱
  • 网站系统怎么做谷歌搜索引擎免费
  • 怎么做网站写手宁波网络营销推广咨询报价
  • 前端怎么在猪八戒网站接单做百度网盘登录入口官网
  • 网站建设完成的时间微信广告投放平台
  • 做网站涉及个人隐私如何查看百度指数
  • 做卡贴的网站深圳百度搜索排名优化
  • 莱芜吧百度贴吧seo排名快速优化
  • 怎么建立一个个人网站如何申请网站域名流程
  • 要绑定税务网站办税员怎样做茂名seo顾问服务
  • 网站建设项目设计表肇庆疫情最新消息
  • html5网站建设思路软文范例大全100
  • 天津今日最新疫情津云太原搜索引擎优化
  • 网站建设中国十强上海百度推广优化
  • 周口公司做网站58同城黄页推广
  • 聊天室网站开发百度指数是干嘛的
  • 网页设计师证书报考条件seo定义
  • 湛江企业网站建设公司怎么做营销推广方案
  • 上海黄浦 网站制作网络优化报告
  • 南京医院网站建设拼多多seo怎么优化
  • 银川市建设诚信平台网站企业网站策划