提交 b2112866 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

fix: page can not scroll

上级 1f9e071b
<template> <template>
<view> <scroll-view>
<page-head title="navigate"></page-head> <page-head title="navigate"></page-head>
<view class="uni-padding-wrap uni-common-mt uni-common-mb"> <view class="uni-padding-wrap uni-common-mt uni-common-mb">
<view class="direction-row"> <view class="direction-row">
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</button> </button>
</view> </view>
</view> </view>
</view> </scroll-view>
</template> </template>
<script lang="uts"> <script lang="uts">
...@@ -341,7 +341,7 @@ export default { ...@@ -341,7 +341,7 @@ export default {
}, },
customAnimation() { customAnimation() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/API/navigator/new-page/new-page-1?data=自定义动画打开页面', url: '/pages/API/navigator/new-page/new-page-2?data=自定义动画打开页面',
animationType: 'slide-in-bottom', animationType: 'slide-in-bottom',
animationDuration: 200, animationDuration: 200,
}) })
......
<template> <template>
<view class="uni-padding-wrap container"> <scroll-view class="uni-padding-wrap">
<view class="container">
<page-head title="new-page-2" /> <page-head title="new-page-2" />
<button @click="scrollToBottom">scrollToBottom</button> <button @click="scrollToBottom">scrollToBottom</button>
</view> </view>
</scroll-view>
</template> </template>
<script lang="uts"> <script lang="uts">
...@@ -15,7 +17,7 @@ export default { ...@@ -15,7 +17,7 @@ export default {
isScrolled: false, isScrolled: false,
} }
}, },
onLoad(_: OnLoadOptions) { onLoad(_ : OnLoadOptions) {
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100) setLifeCycleNum(state.lifeCycleNum + 100)
}, },
...@@ -39,7 +41,7 @@ export default { ...@@ -39,7 +41,7 @@ export default {
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10) setLifeCycleNum(state.lifeCycleNum + 10)
}, },
onBackPress(_: OnBackPressOptions): boolean | null { onBackPress(_ : OnBackPressOptions) : boolean | null {
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10) setLifeCycleNum(state.lifeCycleNum - 10)
return null return null
...@@ -54,11 +56,11 @@ export default { ...@@ -54,11 +56,11 @@ export default {
}, },
methods: { methods: {
// 自动化测试 // 自动化测试
getLifeCycleNum(): number { getLifeCycleNum() : number {
return state.lifeCycleNum return state.lifeCycleNum
}, },
// 自动化测试 // 自动化测试
setLifeCycleNum(num: number) { setLifeCycleNum(num : number) {
setLifeCycleNum(num) setLifeCycleNum(num)
}, },
pullDownRefresh() { pullDownRefresh() {
......
<template> <template>
<view class="uni-container"> <scroll-view class="uni-container">
<view class="uni-header-logo"> <view class="uni-header-logo">
<image class="uni-header-image" src="/static/apiIndex.png"></image> <image class="uni-header-image" src="/static/apiIndex.png"></image>
</view> </view>
<view class="uni-hello-text"> <view class="uni-hello-text">
<text class="hello-text">以下将演示uni-app接口能力,详细文档见:</text> <text class="hello-text">以下将演示uni-app接口能力,详细文档见:</text>
<u-link :href="'https://uniapp.dcloud.io/api/'" :text="'https://uniapp.dcloud.io/api/'" <u-link
:inWhiteList="true"></u-link> :href="'https://uniapp.dcloud.io/api/'"
:text="'https://uniapp.dcloud.io/api/'"
:inWhiteList="true"
></u-link>
</view> </view>
<view class="uni-panel" v-for="(item, index) in list" :key="item.id"> <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)"> <view
<text class="uni-panel-text" :class="item.enable == false ? 'text-disabled' : ''">{{item.name}}</text> class="uni-panel-h"
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon" :class="item.open ? 'uni-panel-h-on' : ''"
class="uni-icon"></image> @click="triggerCollapse(index, item)"
>
<text
class="uni-panel-text"
:class="item.enable == false ? 'text-disabled' : ''"
>{{ item.name }}</text
>
<image
:src="
item.pages.length > 0
? item.open
? arrowUpIcon
: arrowDownIcon
: arrowRightIcon
"
class="uni-icon"
></image>
</view> </view>
<view class="uni-panel-c" v-if="item.open"> <view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)"> <view
<text class="uni-navigate-text" class="uni-navigate-item"
:class="page.enable == false ? 'text-disabled' : ''">{{page.name}}</text> v-for="(page, key) in item.pages"
:key="key"
@click="goDetailPage(page)"
>
<text
class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''"
>{{ page.name }}</text
>
<image :src="arrowRightIcon" class="uni-icon"></image> <image :src="arrowRightIcon" class="uni-icon"></image>
</view> </view>
</view> </view>
</view> </view>
</view> </scroll-view>
</template> </template>
<script lang="ts"> <script lang="ts">
type Page = { type Page = {
name : string, name: string
enable ?: boolean, enable?: boolean
url : string url: string
} }
type ListItem = { type ListItem = {
id : string, id: string
name : string, name: string
open : boolean, open: boolean
pages : Page[], pages: Page[]
url ?: string, url?: string
enable ?: boolean enable?: boolean
} }
export default { export default {
data() { data() {
return { return {
list: [ list: [
{ {
id: "base", id: 'base',
name: "基础", name: '基础',
open: false, open: false,
pages: [ pages: [
{ {
name: "getApp", name: 'getApp',
url: "get-app", url: 'get-app',
}, },
{ {
name: "getCurrentPages", name: 'getCurrentPages',
url: "get-current-pages", url: 'get-current-pages',
}, },
{ {
name: "事件总线event-bus", name: '事件总线event-bus',
url: "event-bus", url: 'event-bus',
}, },
{ {
name: "获取启动参数", name: '获取启动参数',
url: "get-launch-options-sync", url: 'get-launch-options-sync',
} },
] as Page[], ] as Page[],
}, },
{ {
id: "page", id: 'page',
name: "页面", name: '页面',
open: false, open: false,
pages: [ pages: [
{ {
name: "页面跳转", name: '页面跳转',
url: "navigator", url: 'navigator',
}, },
{ {
name: "页面栈管理", name: '页面栈管理',
url: "getCurrentPages", url: 'getCurrentPages',
enable: false enable: false,
}, },
{ {
name: "设置导航条标题", name: '设置导航条标题',
url: "set-navigation-bar-title", url: 'set-navigation-bar-title',
enable: false enable: false,
}, },
{ {
name: "设置导航条颜色", name: '设置导航条颜色',
url: "set-navigation-bar-color", url: 'set-navigation-bar-color',
}, },
{ {
name: "设置TabBar", name: '设置TabBar',
url: "set-tabbar", url: 'set-tabbar',
enable: false enable: false,
}, },
{ {
name: "下拉刷新", name: '下拉刷新',
url: "pull-down-refresh", url: 'pull-down-refresh',
enable: false enable: false,
}, },
{ {
name: "将页面滚动到指定位置", name: '将页面滚动到指定位置',
url: "page-scroll-to", url: 'page-scroll-to',
}, },
] as Page[], ] as Page[],
}, },
{ {
id: "ui", id: 'ui',
name: "界面", name: '界面',
open: false, open: false,
pages: [ pages: [
/* { /* {
...@@ -126,67 +153,67 @@ ...@@ -126,67 +153,67 @@
enable: false enable: false
}, */ }, */
{ {
name: "节点信息", name: '节点信息',
url: "nodes-info" url: 'nodes-info',
}, },
{ {
name: "显示操作菜单", name: '显示操作菜单',
url: "action-sheet", url: 'action-sheet',
}, },
{ {
name: "显示模态弹窗", name: '显示模态弹窗',
url: "modal", url: 'modal',
}, },
{ {
name: "显示加载提示框", name: '显示加载提示框',
url: "show-loading", url: 'show-loading',
}, },
{ {
name: "显示消息提示框", name: '显示消息提示框',
url: "toast", url: 'toast',
}, },
{ {
name: "动态加载字体", name: '动态加载字体',
url: "load-font-face", url: 'load-font-face',
}, },
] as Page[], ] as Page[],
}, },
{ {
id: "device", id: 'device',
name: "设备", name: '设备',
open: false, open: false,
pages: [ pages: [
{ {
name: "获取设备网络状态", name: '获取设备网络状态',
url: "get-network-type", url: 'get-network-type',
}, },
{ {
name: "获取系统信息", name: '获取系统信息',
url: "get-system-info", url: 'get-system-info',
}, },
{ {
name: "获取设备信息", name: '获取设备信息',
url: "get-device-info", url: 'get-device-info',
}, },
{ {
name: "获取APP基础信息", name: '获取APP基础信息',
url: "get-app-base-info", url: 'get-app-base-info',
}, },
{ {
name: "获取系统设置", name: '获取系统设置',
url: "get-system-setting", url: 'get-system-setting',
}, },
{ {
name: "获取APP授权设置", name: '获取APP授权设置',
url: "get-app-authorize-setting", url: 'get-app-authorize-setting',
}, },
{ {
name: "获取窗口信息", name: '获取窗口信息',
url: "get-window-info", url: 'get-window-info',
}, },
{ {
name: "电量", name: '电量',
url: "get-battery-info", url: 'get-battery-info',
}, },
/* { /* {
name: "打电话", name: "打电话",
...@@ -243,47 +270,47 @@ ...@@ -243,47 +270,47 @@
] as Page[], ] as Page[],
}, },
{ {
id: "network", id: 'network',
name: "网络", name: '网络',
open: false, open: false,
pages: [ pages: [
{ {
name: "发起一个请求", name: '发起一个请求',
url: "request", url: 'request',
}, },
{ {
name: "上传文件", name: '上传文件',
url: "upload-file", url: 'upload-file',
}, },
{ {
name: "下载文件", name: '下载文件',
url: "download-file", url: 'download-file',
}, },
] as Page[], ] as Page[],
}, },
{ {
id: "websocket", id: 'websocket',
name: "websocket", name: 'websocket',
open: false, open: false,
pages: [ pages: [
{ {
name: "socketTask", name: 'socketTask',
url: "websocket-socketTask", url: 'websocket-socketTask',
}, },
{ {
name: "全局websocket", name: '全局websocket',
url: "websocket-global", url: 'websocket-global',
}, },
] as Page[], ] as Page[],
}, },
{ {
id: "media", id: 'media',
name: "媒体", name: '媒体',
open: false, open: false,
pages: [ pages: [
{ {
name: "图片选择和预览", name: '图片选择和预览',
url: "preview-image", url: 'preview-image',
}, },
/* { /* {
name: "图片选择和拍照", name: "图片选择和拍照",
...@@ -317,15 +344,15 @@ ...@@ -317,15 +344,15 @@
] as Page[], ] as Page[],
}, },
{ {
id: "location", id: 'location',
name: "位置", name: '位置',
open: false, open: false,
pages: [ pages: [
{ {
name: "获取当前位置", name: '获取当前位置',
url: "get-location", url: 'get-location',
}, },
/* { /* {
name: "使用地图查看位置", name: "使用地图查看位置",
url: "open-location", url: "open-location",
}, },
...@@ -344,17 +371,17 @@ ...@@ -344,17 +371,17 @@
] as Page[], ] as Page[],
}, },
{ {
id: "storage", id: 'storage',
name: "存储", name: '存储',
open: false, open: false,
pages: [ pages: [
{ {
name: "storage(key-value存储)", name: 'storage(key-value存储)',
url: "storage", url: 'storage',
} },
] as Page[], ] as Page[],
}, },
/* { /* {
id: "rewarded-video-ad", id: "rewarded-video-ad",
url: "rewarded-video-ad", url: "rewarded-video-ad",
name: "激励视频广告", name: "激励视频广告",
...@@ -430,17 +457,17 @@ ...@@ -430,17 +457,17 @@
] as Page[], ] as Page[],
}, */ }, */
{ {
id: "exit", id: 'exit',
name: "退出", name: '退出',
open: false, open: false,
pages: [ pages: [
{ {
name: "exit退出", name: 'exit退出',
url: "exit", url: 'exit',
enable: false enable: false,
} },
] as Page[], ] as Page[],
} },
] as ListItem[], ] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png', arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png', arrowDownIcon: '/static/icons/arrow-down.png',
...@@ -448,41 +475,42 @@ ...@@ -448,41 +475,42 @@
} }
}, },
methods: { methods: {
triggerCollapse(index ?: number, item : ListItem) { triggerCollapse(index?: number, item: ListItem) {
if (item.pages.length == 0) { if (item.pages.length == 0) {
const page : Page = { const page: Page = {
name: item.name, name: item.name,
enable: item.enable, enable: item.enable,
url: item.url! url: item.url!,
} }
this.goDetailPage(page); this.goDetailPage(page)
return; return
} }
for (var i = 0; i < this.list.length; ++i) { for (var i = 0; i < this.list.length; ++i) {
if (index == i) { if (index == i) {
this.list[i].open = !this.list[i].open; this.list[i].open = !this.list[i].open
} else { } else {
this.list[i].open = false; this.list[i].open = false
} }
} }
}, },
goDetailPage(e : Page) { goDetailPage(e: Page) {
if (e.enable == false) { if (e.enable == false) {
uni.showToast({ uni.showToast({
title: '暂不支持', title: '暂不支持',
icon:"none" icon: 'none',
}) })
return return
} }
const url = e.url.indexOf('platform') > -1 ? e.url : `/pages/API/${e.url}/${e.url}` const url =
e.url.indexOf('platform') > -1 ? e.url : `/pages/API/${e.url}/${e.url}`
uni.navigateTo({ uni.navigateTo({
url url,
}) })
} },
} },
} }
</script> </script>
<style> <style>
@import '../../common/uni-uvue.css'; @import '../../common/uni-uvue.css';
</style> </style>
<template> <template>
<view class="uni-container"> <scroll-view class="uni-container">
<view class="uni-header-logo"> <view class="uni-header-logo">
<image class="uni-header-image" src="/static/cssIndex.png"></image> <image class="uni-header-image" src="/static/cssIndex.png"></image>
</view> </view>
<view class="uni-hello-text"> <view class="uni-hello-text">
<text class="hello-text">uni-app x目前已支持的CSS属性,展示样式仅供参考,文档详见:</text> <text class="hello-text"
<u-link :href="'https://uniapp.dcloud.io/component/'" :text="'https://uniapp.dcloud.io/component/'" :inWhiteList="true"></u-link> >uni-app x目前已支持的CSS属性,展示样式仅供参考,文档详见:</text
>
<u-link
:href="'https://uniapp.dcloud.io/component/'"
:text="'https://uniapp.dcloud.io/component/'"
:inWhiteList="true"
></u-link>
</view> </view>
<view class="uni-panel" v-for="(item, index) in list" :key="item.id"> <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)"> <view
<text class="uni-panel-text" :class="item.enable == false ? 'text-disabled' : ''">{{item.name}}</text> class="uni-panel-h"
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon" class="uni-icon"></image> :class="item.open ? 'uni-panel-h-on' : ''"
@click="triggerCollapse(index, item)"
>
<text
class="uni-panel-text"
:class="item.enable == false ? 'text-disabled' : ''"
>{{ item.name }}</text
>
<image
:src="
item.pages.length > 0
? item.open
? arrowUpIcon
: arrowDownIcon
: arrowRightIcon
"
class="uni-icon"
></image>
</view> </view>
<view class="uni-panel-c" v-if="item.open"> <view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)"> <view
<text class="uni-navigate-text" :class="page.enable == false ? 'text-disabled' : ''">{{page.name}}</text> class="uni-navigate-item"
v-for="(page, key) in item.pages"
:key="key"
@click="goDetailPage(page)"
>
<text
class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''"
>{{ page.name }}</text
>
<image :src="arrowRightIcon" class="uni-icon"></image> <image :src="arrowRightIcon" class="uni-icon"></image>
</view> </view>
</view> </view>
</view> </view>
</view> </scroll-view>
</template> </template>
<script lang="ts"> <script lang="ts">
type Page = { type Page = {
name : string, name: string
enable ?: boolean, enable?: boolean
url ?: string url?: string
} }
type ListItem = { type ListItem = {
id : string, id: string
name : string, name: string
open : boolean, open: boolean
pages : Page[], pages: Page[]
url ?: string, url?: string
enable ?: boolean enable?: boolean
} }
export default { export default {
data() { data() {
return { return {
list: [{ list: [
{
id: 'background', id: 'background',
name: 'background', name: 'background',
open: false, open: false,
pages: [ pages: [
{ {
name: 'background-color', name: 'background-color',
url: '/pages/CSS/background/background-color' url: '/pages/CSS/background/background-color',
}, },
{ {
name: 'background-image', name: 'background-image',
url: '/pages/CSS/background/background-image' url: '/pages/CSS/background/background-image',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'border', id: 'border',
name: 'border', name: 'border',
open: false, open: false,
pages: [ pages: [
{ {
name: 'border', name: 'border',
url: '/pages/CSS/border/border' url: '/pages/CSS/border/border',
}, },
{ {
name: 'border-width', name: 'border-width',
url: '/pages/CSS/border/border-width' url: '/pages/CSS/border/border-width',
}, },
{ {
name: 'border-style', name: 'border-style',
url: '/pages/CSS/border/border-style' url: '/pages/CSS/border/border-style',
}, },
{ {
name: 'border-color', name: 'border-color',
url: '/pages/CSS/border/border-color' url: '/pages/CSS/border/border-color',
}, },
{ {
name: 'border-radius', name: 'border-radius',
url: '/pages/CSS/border/border-radius' url: '/pages/CSS/border/border-radius',
}, },
{ {
name: 'border属性复合示例', name: 'border属性复合示例',
url: '/pages/CSS/border/complex-border/complex-border' url: '/pages/CSS/border/complex-border/complex-border',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'box-shadow', id: 'box-shadow',
name: 'box-shadow', name: 'box-shadow',
open: false, open: false,
pages: [ pages: [
{ {
name: 'box-shadow', name: 'box-shadow',
url: '/pages/CSS/box-shadow/box-shadow' url: '/pages/CSS/box-shadow/box-shadow',
}, },
] as Page[] ] as Page[],
}, { },
{
id: 'flex', id: 'flex',
name: 'flex', name: 'flex',
open: false, open: false,
pages: [ pages: [
{ {
name: 'align-content', name: 'align-content',
url: '/pages/CSS/flex/align-content' url: '/pages/CSS/flex/align-content',
}, },
{ {
name: 'align-items', name: 'align-items',
url: '/pages/CSS/flex/align-items' url: '/pages/CSS/flex/align-items',
}, },
{ {
name: 'flex-basis', name: 'flex-basis',
url: '/pages/CSS/flex/flex-basis' url: '/pages/CSS/flex/flex-basis',
}, },
{ {
name: 'flex-direction', name: 'flex-direction',
url: '/pages/CSS/flex/flex-direction' url: '/pages/CSS/flex/flex-direction',
}, },
{ {
name: 'flex-flow', name: 'flex-flow',
url: '/pages/CSS/flex/flex-flow' url: '/pages/CSS/flex/flex-flow',
}, },
{ {
name: 'flex-grow', name: 'flex-grow',
url: '/pages/CSS/flex/flex-grow' url: '/pages/CSS/flex/flex-grow',
}, },
{ {
name: 'flex-shrink', name: 'flex-shrink',
url: '/pages/CSS/flex/flex-shrink' url: '/pages/CSS/flex/flex-shrink',
}, },
{ {
name: 'flex', name: 'flex',
url: '/pages/CSS/flex/flex' url: '/pages/CSS/flex/flex',
}, },
{ {
name: 'justify-content', name: 'justify-content',
url: '/pages/CSS/flex/justify-content' url: '/pages/CSS/flex/justify-content',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'layout', id: 'layout',
name: 'layout', name: 'layout',
open: false, open: false,
pages: [ pages: [
{ {
name: 'height', name: 'height',
url: '/pages/CSS/layout/height' url: '/pages/CSS/layout/height',
}, },
{ {
name: 'max-height', name: 'max-height',
url: '/pages/CSS/layout/max-height' url: '/pages/CSS/layout/max-height',
}, },
{ {
name: 'max-width', name: 'max-width',
url: '/pages/CSS/layout/max-width' url: '/pages/CSS/layout/max-width',
}, },
{ {
name: 'min-height', name: 'min-height',
url: '/pages/CSS/layout/min-height' url: '/pages/CSS/layout/min-height',
}, },
{ {
name: 'min-width', name: 'min-width',
url: '/pages/CSS/layout/min-width' url: '/pages/CSS/layout/min-width',
}, },
{ {
name: 'position', name: 'position',
url: '/pages/CSS/layout/position' url: '/pages/CSS/layout/position',
}, },
{ {
name: 'width', name: 'width',
url: '/pages/CSS/layout/width' url: '/pages/CSS/layout/width',
}, },
{ {
name: 'visibility', name: 'visibility',
url: '/pages/CSS/layout/visibility' url: '/pages/CSS/layout/visibility',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'margin', id: 'margin',
name: 'margin', name: 'margin',
open: false, open: false,
pages: [ pages: [
{ {
name: 'margin-bottom', name: 'margin-bottom',
url: '/pages/CSS/margin/margin-bottom' url: '/pages/CSS/margin/margin-bottom',
}, },
{ {
name: 'margin-left', name: 'margin-left',
url: '/pages/CSS/margin/margin-left' url: '/pages/CSS/margin/margin-left',
}, },
{ {
name: 'margin-right', name: 'margin-right',
url: '/pages/CSS/margin/margin-right' url: '/pages/CSS/margin/margin-right',
}, },
{ {
name: 'margin-top', name: 'margin-top',
url: '/pages/CSS/margin/margin-top' url: '/pages/CSS/margin/margin-top',
}, { },
{
name: 'margin', name: 'margin',
url: '/pages/CSS/margin/margin' url: '/pages/CSS/margin/margin',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'padding', id: 'padding',
name: 'padding', name: 'padding',
open: false, open: false,
pages: [ pages: [
{ {
name: 'padding-bottom', name: 'padding-bottom',
url: '/pages/CSS/padding/padding-bottom' url: '/pages/CSS/padding/padding-bottom',
}, },
{ {
name: 'padding-left', name: 'padding-left',
url: '/pages/CSS/padding/padding-left' url: '/pages/CSS/padding/padding-left',
}, },
{ {
name: 'padding-right', name: 'padding-right',
url: '/pages/CSS/padding/padding-right' url: '/pages/CSS/padding/padding-right',
}, },
{ {
name: 'padding-top', name: 'padding-top',
url: '/pages/CSS/padding/padding-top' url: '/pages/CSS/padding/padding-top',
}, { },
{
name: 'padding', name: 'padding',
url: '/pages/CSS/padding/padding' url: '/pages/CSS/padding/padding',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'text', id: 'text',
name: 'text', name: 'text',
open: false, open: false,
pages: [ pages: [
{ {
name: 'color', name: 'color',
url: '/pages/CSS/text/color' url: '/pages/CSS/text/color',
}, },
{ {
name: 'font-family', name: 'font-family',
url: '/pages/CSS/text/font-family' url: '/pages/CSS/text/font-family',
}, },
{ {
name: 'font-size', name: 'font-size',
url: '/pages/CSS/text/font-size' url: '/pages/CSS/text/font-size',
}, },
{ {
name: 'font-style', name: 'font-style',
url: '/pages/CSS/text/font-style' url: '/pages/CSS/text/font-style',
}, },
{ {
name: 'font-weight', name: 'font-weight',
url: '/pages/CSS/text/font-weight' url: '/pages/CSS/text/font-weight',
}, },
{ {
name: 'line-height', name: 'line-height',
url: '/pages/CSS/text/line-height' url: '/pages/CSS/text/line-height',
}, },
{ {
name: 'text-align', name: 'text-align',
url: '/pages/CSS/text/text-align' url: '/pages/CSS/text/text-align',
}, },
{ {
name: 'text-overflow', name: 'text-overflow',
url: '/pages/CSS/text/text-overflow' url: '/pages/CSS/text/text-overflow',
}, },
{ {
name: 'text-decoration-line', name: 'text-decoration-line',
url: '/pages/CSS/text/text-decoration-line' url: '/pages/CSS/text/text-decoration-line',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'animate', id: 'animate',
name: '动画', name: '动画',
open: false, open: false,
pages: [ pages: [
{ {
name: 'transition', name: 'transition',
url: '/pages/CSS/transition/transition' url: '/pages/CSS/transition/transition',
}, },
{ {
name: 'transform', name: 'transform',
url: '/pages/CSS/transform/transform' url: '/pages/CSS/transform/transform',
} },
] as Page[] ] as Page[],
} },
] as ListItem[], ] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png', arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png', arrowDownIcon: '/static/icons/arrow-down.png',
...@@ -287,41 +330,41 @@ ...@@ -287,41 +330,41 @@
} }
}, },
methods: { methods: {
triggerCollapse(index ?: number, item : ListItem) { triggerCollapse(index?: number, item: ListItem) {
if (item.pages.length == 0) { if (item.pages.length == 0) {
const page : Page = { const page: Page = {
name: item.name, name: item.name,
enable: item.enable, enable: item.enable,
url: item.url url: item.url,
} }
this.goDetailPage(page); this.goDetailPage(page)
return; return
} }
for (var i = 0; i < this.list.length; ++i) { for (var i = 0; i < this.list.length; ++i) {
if (index == i) { if (index == i) {
this.list[i].open = !this.list[i].open; this.list[i].open = !this.list[i].open
} else { } else {
this.list[i].open = false; this.list[i].open = false
} }
} }
}, },
goDetailPage(e : Page) { goDetailPage(e: Page) {
if (e.enable == false) { if (e.enable == false) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '暂不支持' title: '暂不支持',
}) })
return return
} }
const url = e.url != null ? e.url! : `/pages/CSS/${e.name}/${e.name}` const url = e.url != null ? e.url! : `/pages/CSS/${e.name}/${e.name}`
uni.navigateTo({ uni.navigateTo({
url url,
}) })
} },
} },
} }
</script> </script>
<style> <style>
@import '../../common/uni-uvue.css'; @import '../../common/uni-uvue.css';
</style> </style>
<template> <template>
<view class="uni-container"> <scroll-view class="uni-container">
<view class="uni-header-logo"> <view class="uni-header-logo">
<image class="uni-header-image" src="/static/componentIndex.png"></image> <image class="uni-header-image" src="/static/componentIndex.png"></image>
</view> </view>
<view class="uni-hello-text"> <view class="uni-hello-text">
<text class="hello-text">uni-app内置组件,展示样式仅供参考,文档详见:</text> <text class="hello-text"
<u-link :href="'https://uniapp.dcloud.io/component/'" :text="'https://uniapp.dcloud.io/component/'" >uni-app内置组件,展示样式仅供参考,文档详见:</text
:inWhiteList="true"></u-link> >
<u-link
:href="'https://uniapp.dcloud.io/component/'"
:text="'https://uniapp.dcloud.io/component/'"
:inWhiteList="true"
></u-link>
</view> </view>
<view class="uni-panel" v-for="(item, index) in list" :key="item.id"> <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)"> <view
<text class="uni-panel-text" :class="item.enable == false ? 'text-disabled' : ''">{{item.name}}</text> class="uni-panel-h"
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon" :class="item.open ? 'uni-panel-h-on' : ''"
class="uni-icon"></image> @click="triggerCollapse(index, item)"
>
<text
class="uni-panel-text"
:class="item.enable == false ? 'text-disabled' : ''"
>{{ item.name }}</text
>
<image
:src="
item.pages.length > 0
? item.open
? arrowUpIcon
: arrowDownIcon
: arrowRightIcon
"
class="uni-icon"
></image>
</view> </view>
<view class="uni-panel-c" v-if="item.open"> <view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)"> <view
<text class="uni-navigate-text" class="uni-navigate-item"
:class="page.enable == false ? 'text-disabled' : ''">{{page.name}}</text> v-for="(page, key) in item.pages"
:key="key"
@click="goDetailPage(page)"
>
<text
class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''"
>{{ page.name }}</text
>
<image :src="arrowRightIcon" class="uni-icon"></image> <image :src="arrowRightIcon" class="uni-icon"></image>
</view> </view>
</view> </view>
</view> </view>
</view> </scroll-view>
</template> </template>
<script lang="ts"> <script lang="ts">
type Page = { type Page = {
name : string, name: string
enable ?: boolean, enable?: boolean
url ?: string url?: string
} }
type ListItem = { type ListItem = {
id : string, id: string
name : string, name: string
open : boolean, open: boolean
pages : Page[], pages: Page[]
url ?: string, url?: string
enable ?: boolean enable?: boolean
} }
export default { export default {
data() { data() {
return { return {
list: [{ list: [
{
id: 'view', id: 'view',
name: '视图容器', name: '视图容器',
open: false, open: false,
...@@ -68,14 +98,15 @@ ...@@ -68,14 +98,15 @@
*/ */
{ {
name: 'list(新闻)', name: 'list(新闻)',
url: "/pages/component/list/list", url: '/pages/component/list/list',
}, },
{ {
name: 'list', name: 'list',
url: "/pages/component/long-list/long-list", url: '/pages/component/long-list/long-list',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'content', id: 'content',
name: '基础内容', name: '基础内容',
open: false, open: false,
...@@ -85,13 +116,14 @@ ...@@ -85,13 +116,14 @@
}, },
{ {
name: 'rich-text', name: 'rich-text',
enable: false enable: false,
}, },
{ {
name: 'progress', name: 'progress',
} },
] as Page[] ] as Page[],
}, { },
{
id: 'form', id: 'form',
name: '表单组件', name: '表单组件',
open: false, open: false,
...@@ -114,17 +146,23 @@ ...@@ -114,17 +146,23 @@
}, { }, {
name: 'picker', name: 'picker',
enable: false */ enable: false */
}, { },
name: 'picker-view' {
}, { name: 'picker-view',
},
{
name: 'radio', name: 'radio',
}, { },
{
name: 'slider', name: 'slider',
}, { },
{
name: 'slider-100', name: 'slider-100',
}, { },
{
name: 'switch', name: 'switch',
}, { },
{
name: 'textarea', name: 'textarea',
}, },
/* /*
...@@ -133,7 +171,7 @@ ...@@ -133,7 +171,7 @@
enable: false enable: false
}, },
*/ */
] as Page[] ] as Page[],
/* }, { /* }, {
id: 'nav', id: 'nav',
name: '导航', name: '导航',
...@@ -142,20 +180,25 @@ ...@@ -142,20 +180,25 @@
name: 'navigator', name: 'navigator',
enable: false enable: false
}] as Page[] */ }] as Page[] */
}, { },
{
id: 'media', id: 'media',
name: '媒体组件', name: '媒体组件',
open: false, open: false,
pages: [{ pages: [
{
name: 'image', name: 'image',
enable: true enable: true,
}, { },
{
name: 'video', name: 'video',
enable: true enable: true,
}, { },
{
name: 'animation-view', name: 'animation-view',
enable: false enable: false,
}] as Page[] },
] as Page[],
}, },
/* /*
{ {
...@@ -188,14 +231,14 @@ ...@@ -188,14 +231,14 @@
{ {
name: '网络网页', name: '网络网页',
enable: true, enable: true,
url: '/pages/component/web-view/web-view' url: '/pages/component/web-view/web-view',
}, },
{ {
name: '本地网页', name: '本地网页',
enable: true, enable: true,
url: '/pages/component/web-view-local/web-view-local' url: '/pages/component/web-view-local/web-view-local',
} },
] as Page[] ] as Page[],
}, },
/* /*
{ {
...@@ -208,18 +251,19 @@ ...@@ -208,18 +251,19 @@
} }
*/ */
{ {
id: "general-attr-event", id: 'general-attr-event',
name: "通用属性和事件", name: '通用属性和事件',
open: false, open: false,
pages: [ pages: [
{ {
name: "通用属性", name: '通用属性',
url: "general-attr", url: 'general-attr',
enable: false enable: false,
},{ },
name: "通用事件", {
url: "general-event", name: '通用事件',
enable: false url: 'general-event',
enable: false,
}, },
] as Page[], ] as Page[],
}, },
...@@ -230,41 +274,42 @@ ...@@ -230,41 +274,42 @@
} }
}, },
methods: { methods: {
triggerCollapse(index ?: number, item : ListItem) { triggerCollapse(index?: number, item: ListItem) {
if (item.pages.length == 0) { if (item.pages.length == 0) {
const page : Page = { const page: Page = {
name: item.name, name: item.name,
enable: item.enable, enable: item.enable,
url: item.url url: item.url,
} }
this.goDetailPage(page); this.goDetailPage(page)
return; return
} }
for (var i = 0; i < this.list.length; ++i) { for (var i = 0; i < this.list.length; ++i) {
if (index == i) { if (index == i) {
this.list[i].open = !this.list[i].open; this.list[i].open = !this.list[i].open
} else { } else {
this.list[i].open = false; this.list[i].open = false
} }
} }
}, },
goDetailPage(e : Page) { goDetailPage(e: Page) {
if (e.enable == false) { if (e.enable == false) {
uni.showToast({ uni.showToast({
title: '暂不支持', title: '暂不支持',
icon: 'none' icon: 'none',
}) })
return return
} }
const url = e.url != null ? e.url! : `/pages/component/${e.name}/${e.name}` const url =
e.url != null ? e.url! : `/pages/component/${e.name}/${e.name}`
uni.navigateTo({ uni.navigateTo({
url url,
}) })
} },
} },
} }
</script> </script>
<style> <style>
@import '../../common/uni-uvue.css'; @import '../../common/uni-uvue.css';
</style> </style>
<template> <template>
<view class="uni-container"> <scroll-view class="uni-container">
<view class="uni-header-logo"> <view class="uni-header-logo">
<image class="uni-header-image" src="/static/templateIndex.png"></image> <image class="uni-header-image" src="/static/templateIndex.png"></image>
</view> </view>
<view class="uni-hello-text"> <view class="uni-hello-text">
<text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text> <text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text>
<u-link class="hello-link" href="https://ext.dcloud.net.cn" :text="'https://ext.dcloud.net.cn'" <u-link
:inWhiteList="true"></u-link> class="hello-link"
href="https://ext.dcloud.net.cn"
:text="'https://ext.dcloud.net.cn'"
:inWhiteList="true"
></u-link>
</view> </view>
<view class="uni-panel" v-for="(item, index) in list" :key="item.id"> <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)"> <view
<text class="uni-panel-text" :class="item.enable == false ? 'text-disabled' : ''">{{item.name}}</text> class="uni-panel-h"
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon" :class="item.open ? 'uni-panel-h-on' : ''"
class="uni-icon"> @click="triggerCollapse(index, item)"
>
<text
class="uni-panel-text"
:class="item.enable == false ? 'text-disabled' : ''"
>{{ item.name }}</text
>
<image
:src="
item.pages.length > 0
? item.open
? arrowUpIcon
: arrowDownIcon
: arrowRightIcon
"
class="uni-icon"
>
</image> </image>
</view> </view>
<view class="uni-panel-c" v-if="item.open"> <view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)"> <view
<text class="uni-navigate-text" class="uni-navigate-item"
:class="page.enable == false ? 'text-disabled' : ''">{{page.name}}</text> v-for="(page, key) in item.pages"
:key="key"
@click="goDetailPage(page)"
>
<text
class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''"
>{{ page.name }}</text
>
<image :src="arrowRightIcon" class="uni-icon"></image> <image :src="arrowRightIcon" class="uni-icon"></image>
</view> </view>
</view> </view>
</view> </view>
</view> </scroll-view>
</template> </template>
<script lang="ts"> <script lang="ts">
type Page = { type Page = {
name : string, name: string
enable ?: boolean, enable?: boolean
url : string url: string
} }
type ListItem = { type ListItem = {
id : string, id: string
name : string, name: string
open : boolean, open: boolean
pages : Page[], pages: Page[]
url ?: string, url?: string
enable ?: boolean enable?: boolean
} }
export default { export default {
data() { data() {
return { return {
list: [ list: [
{ {
id: "long-list", id: 'long-list',
url: "long-list", url: 'long-list',
name: "复杂长列表", name: '复杂长列表',
open: false, open: false,
enable: false, enable: false,
pages: [] as Page[] pages: [] as Page[],
},{ },
id: "scroll-fold-nav", {
url: "scroll-fold-nav", id: 'scroll-fold-nav',
name: "随滚动折叠的导航栏", url: 'scroll-fold-nav',
name: '随滚动折叠的导航栏',
open: false, open: false,
pages: [] as Page[] pages: [] as Page[],
},{ },
id: "scroll-fold-nav2", {
url: "scroll-fold-nav2", id: 'scroll-fold-nav2',
name: "随滚动折叠的导航栏2", url: 'scroll-fold-nav2',
name: '随滚动折叠的导航栏2',
open: false, open: false,
pages: [] as Page[] pages: [] as Page[],
}, { },
id: "swiper-list", {
url: "swiper-list", id: 'swiper-list',
name: "swiper-list", url: 'swiper-list',
name: 'swiper-list',
open: false, open: false,
enable: false, enable: false,
pages: [] as Page[] pages: [] as Page[],
},
}, { {
id: "custom-refresher", id: 'custom-refresher',
url: "custom-refresher", url: 'custom-refresher',
name: "自定义下拉刷新", name: '自定义下拉刷新',
open: false, open: false,
pages: [] as Page[] pages: [] as Page[],
}, },
{ {
id: "pull-zoom-image", id: 'pull-zoom-image',
url: "pull-zoom-image", url: 'pull-zoom-image',
name: "下拉缩放顶部封面图", name: '下拉缩放顶部封面图',
open: false, open: false,
enable: false, enable: false,
pages: [] as Page[] pages: [] as Page[],
}, },
{ {
id: "show-search-with-scroll", id: 'show-search-with-scroll',
url: "show-search-with-scroll", url: 'show-search-with-scroll',
name: "滚动后自动显隐的搜索框", name: '滚动后自动显隐的搜索框',
open: false, open: false,
enable: false, enable: false,
pages: [] as Page[] pages: [] as Page[],
}, },
{ {
id: "swiper-vertical-video", id: 'swiper-vertical-video',
url: "swiper-vertical-video", url: 'swiper-vertical-video',
name: "竖滑视频", name: '竖滑视频',
open: false, open: false,
pages: [] as Page[] pages: [] as Page[],
}, },
{ {
id: "scroll-sticky", id: 'scroll-sticky',
url: "scroll-sticky", url: 'scroll-sticky',
name: "吸顶", name: '吸顶',
open: false, open: false,
pages: [] as Page[] pages: [] as Page[],
}, },
{ {
id: "half-screen", id: 'half-screen',
url: "half-screen", url: 'half-screen',
name: "半屏弹窗", name: '半屏弹窗',
open: false, open: false,
pages: [] as Page[] pages: [] as Page[],
}, },
{ {
id: "drop-card", id: 'drop-card',
url: "drop-card", url: 'drop-card',
name: "划走式卡片", name: '划走式卡片',
open: false, open: false,
pages: [] as Page[] pages: [] as Page[],
}, },
{ {
id: "calendar", id: 'calendar',
url: "calendar", url: 'calendar',
name: "日历", name: '日历',
open: false, open: false,
pages: [] as Page[] pages: [] as Page[],
} },
] as ListItem[], ] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png', arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png', arrowDownIcon: '/static/icons/arrow-down.png',
...@@ -137,41 +168,44 @@ ...@@ -137,41 +168,44 @@
} }
}, },
methods: { methods: {
triggerCollapse(index ?: number, item : ListItem) { triggerCollapse(index?: number, item: ListItem) {
if (item.pages.length == 0) { if (item.pages.length == 0) {
const page : Page = { const page: Page = {
name: item.name, name: item.name,
enable: item.enable, enable: item.enable,
url: item.url! url: item.url!,
} }
this.goDetailPage(page); this.goDetailPage(page)
return; return
} }
for (var i = 0; i < this.list.length; ++i) { for (var i = 0; i < this.list.length; ++i) {
if (index == i) { if (index == i) {
this.list[i].open = !this.list[i].open; this.list[i].open = !this.list[i].open
} else { } else {
this.list[i].open = false; this.list[i].open = false
} }
} }
}, },
goDetailPage(e : Page) { goDetailPage(e: Page) {
if (e.enable == false) { if (e.enable == false) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '暂不支持' title: '暂不支持',
}) })
return return
} }
const url = e.url.indexOf('platform') > -1 ? e.url : `/pages/template/${e.url}/${e.url}` const url =
e.url.indexOf('platform') > -1
? e.url
: `/pages/template/${e.url}/${e.url}`
uni.navigateTo({ uni.navigateTo({
url url,
}) })
} },
} },
} }
</script> </script>
<style> <style>
@import '../../common/uni-uvue.css'; @import '../../common/uni-uvue.css';
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册