Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
cda2c837
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cda2c837
编写于
11月 10, 2023
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复this需要在箭头函数内使用
xxx
上级
42458fe4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
282 addition
and
282 deletion
+282
-282
pages/API/loading/loading.uvue
pages/API/loading/loading.uvue
+2
-2
pages/API/modal/modal.uvue
pages/API/modal/modal.uvue
+151
-151
pages/API/request/request.uvue
pages/API/request/request.uvue
+1
-1
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
...navigation-bar-color/set-custom-navigation-bar-color.uvue
+6
-6
pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
...PI/set-navigation-bar-color/set-navigation-bar-color.uvue
+6
-6
pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
...PI/set-navigation-bar-title/set-navigation-bar-title.uvue
+3
-3
pages/API/toast/toast.uvue
pages/API/toast/toast.uvue
+113
-113
未找到文件。
pages/API/loading/loading.uvue
浏览文件 @
cda2c837
...
...
@@ -85,7 +85,7 @@
mask: this.maskSelect
});
}
setTimeout(
function ()
{
setTimeout(
() =>
{
this.hideLoading();
}, 3000);
},
...
...
@@ -94,4 +94,4 @@
}
}
}
</script>
\ No newline at end of file
</script>
pages/API/modal/modal.uvue
浏览文件 @
cda2c837
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-list">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.value"
:checked="index === current">
{{ item.name }}
</radio>
</radio-group>
</view>
<view class="uni-list">
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否显示取消按钮</view>
<switch :checked="showCancelSelect" @change="showCancelChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">定制取消文案</view>
<switch :checked="cancelTextSelect" @change="cancelTextChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">定制确认文案</view>
<switch :checked="confirmTextSelect" @change="confirmTextChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否显示输入框</view>
<switch :checked="editableSelect" @change="editableChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否定制输入提示词</view>
<switch :checked="placeholderTextSelect" @change="placeholderTextChange" />
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="modalTap">
modal测试
</button>
</view>
<text>{{ exeRet }}</text>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
type ItemType = {
value : string,
name : string,
}
export default {
data() {
return {
title: 'modal',
showCancelSelect: false,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
exeRet: "",
items: [{
value: '标题',
name: '有标题'
},
{
value: '',
name: '无标题'
},
{
value: '超长标题测试内容,测试超过显示最大范围之后的样式-超长标题测试内容,测试超过显示最大范围之后的样式',
name: '超长标题'
}
] as ItemType[],
current: 0
}
},
methods: {
showCancelChange: function (e : SwitchChangeEvent) {
this.showCancelSelect = e.detail.value
},
cancelTextChange: function (e : SwitchChangeEvent) {
this.cancelTextSelect = e.detail.value
},
confirmTextChange: function (e : SwitchChangeEvent) {
this.confirmTextSelect = e.detail.value
},
editableChange: function (e : SwitchChangeEvent) {
this.editableSelect = e.detail.value
},
placeholderTextChange: function (e : SwitchChangeEvent) {
this.placeholderTextSelect = e.detail.value
},
radioChange(e : RadioGroupChangeEvent) {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value === e.detail.value) {
this.current = i;
break;
}
}
},
modalTap: function () {
let cancelTextVal : string
let cancelColorVal = ''
if (this.cancelTextSelect) {
cancelTextVal = "修改后的取消文本"
cancelColorVal = "#ff00ff"
} else {
cancelTextVal = "取消"
}
let confirmTextVal = '确定'
let confirmColorVal = ''
if (this.confirmTextSelect) {
confirmTextVal = "修改后的确定文本"
confirmColorVal = "#00ffff"
}
let placeholderTextVal = ''
let contentVal = "弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内"
if (this.placeholderTextSelect) {
placeholderTextVal = "定制提示信息"
contentVal = ""
}
uni.showModal({
title: this.items[this.current].value,
editable: this.editableSelect,
placeholderText: placeholderTextVal,
content: contentVal,
showCancel: this.showCancelSelect,
cancelText: cancelTextVal,
cancelColor: cancelColorVal,
confirmText: confirmTextVal,
confirmColor: confirmColorVal,
success: function (res) {
this.exeRet = JSON.stringify(res)
},
fail: function (res) {
this.exeRet = JSON.stringify(res)
}
})
}
}
}
</script>
\ No newline at end of file
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-list">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.value"
:checked="index === current">
{{ item.name }}
</radio>
</radio-group>
</view>
<view class="uni-list">
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否显示取消按钮</view>
<switch :checked="showCancelSelect" @change="showCancelChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">定制取消文案</view>
<switch :checked="cancelTextSelect" @change="cancelTextChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">定制确认文案</view>
<switch :checked="confirmTextSelect" @change="confirmTextChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否显示输入框</view>
<switch :checked="editableSelect" @change="editableChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否定制输入提示词</view>
<switch :checked="placeholderTextSelect" @change="placeholderTextChange" />
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="modalTap">
modal测试
</button>
</view>
<text>{{ exeRet }}</text>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
type ItemType = {
value : string,
name : string,
}
export default {
data() {
return {
title: 'modal',
showCancelSelect: false,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
exeRet: "",
items: [{
value: '标题',
name: '有标题'
},
{
value: '',
name: '无标题'
},
{
value: '超长标题测试内容,测试超过显示最大范围之后的样式-超长标题测试内容,测试超过显示最大范围之后的样式',
name: '超长标题'
}
] as ItemType[],
current: 0
}
},
methods: {
showCancelChange: function (e : SwitchChangeEvent) {
this.showCancelSelect = e.detail.value
},
cancelTextChange: function (e : SwitchChangeEvent) {
this.cancelTextSelect = e.detail.value
},
confirmTextChange: function (e : SwitchChangeEvent) {
this.confirmTextSelect = e.detail.value
},
editableChange: function (e : SwitchChangeEvent) {
this.editableSelect = e.detail.value
},
placeholderTextChange: function (e : SwitchChangeEvent) {
this.placeholderTextSelect = e.detail.value
},
radioChange(e : RadioGroupChangeEvent) {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value === e.detail.value) {
this.current = i;
break;
}
}
},
modalTap: function () {
let cancelTextVal : string
let cancelColorVal = ''
if (this.cancelTextSelect) {
cancelTextVal = "修改后的取消文本"
cancelColorVal = "#ff00ff"
} else {
cancelTextVal = "取消"
}
let confirmTextVal = '确定'
let confirmColorVal = ''
if (this.confirmTextSelect) {
confirmTextVal = "修改后的确定文本"
confirmColorVal = "#00ffff"
}
let placeholderTextVal = ''
let contentVal = "弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内"
if (this.placeholderTextSelect) {
placeholderTextVal = "定制提示信息"
contentVal = ""
}
uni.showModal({
title: this.items[this.current].value,
editable: this.editableSelect,
placeholderText: placeholderTextVal,
content: contentVal,
showCancel: this.showCancelSelect,
cancelText: cancelTextVal,
cancelColor: cancelColorVal,
confirmText: confirmTextVal,
confirmColor: confirmColorVal,
success: (res) => {
this.exeRet = JSON.stringify(res)
},
fail: (res) => {
this.exeRet = JSON.stringify(res)
}
})
}
}
}
</script>
pages/API/request/request.uvue
浏览文件 @
cda2c837
...
...
@@ -239,4 +239,4 @@
}
}
}
</script>
\ No newline at end of file
</script>
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
浏览文件 @
cda2c837
...
...
@@ -47,16 +47,16 @@ export default {
uni.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: '#0000',
success
()
{
success
: () =>
{
this.navigationBarTextColor = '#fff'
console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail
()
{
fail
: () =>
{
console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete
()
{
complete
: () =>
{
console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
...
...
@@ -66,16 +66,16 @@ export default {
uni.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#0000',
success
()
{
success
: () =>
{
this.navigationBarTextColor = '#000'
console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail
()
{
fail
: () =>
{
console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete
()
{
complete
: () =>
{
console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
...
...
pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
浏览文件 @
cda2c837
...
...
@@ -24,15 +24,15 @@ export default {
uni.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: '#00ff00',
success
()
{
success
: () =>
{
console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail
()
{
fail
: () =>
{
console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete
()
{
complete
: () =>
{
console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
...
...
@@ -42,15 +42,15 @@ export default {
uni.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#ff0000',
success
()
{
success
: () =>
{
console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail
()
{
fail
: () =>
{
console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete
()
{
complete
: () =>
{
console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
...
...
pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
浏览文件 @
cda2c837
...
...
@@ -26,15 +26,15 @@ export default {
setNavigationBarNewTitle() {
uni.setNavigationBarTitle({
title: this.newTitle,
success
()
{
success
: () =>
{
console.log('setNavigationBarTitle success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail
()
{
fail
: () =>
{
console.log('setNavigationBarTitle fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete
()
{
complete
: () =>
{
console.log('setNavigationBarTitle complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
...
...
pages/API/toast/toast.uvue
浏览文件 @
cda2c837
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="toast1Tap">点击弹出默认toast</button>
<button class="uni-btn-v" type="default" @tap="toastTapIconError">点击弹出设置icon的toast</button>
<button class="uni-btn-v" type="default" @tap="toast2Tap">点击弹出设置duration的toast</button>
<button class="uni-btn-v" type="default" @tap="toast3Tap">点击弹出显示loading的toast</button>
<!-- #ifndef MP-ALIPAY -->
<button class="uni-btn-v" type="default" @tap="toast4Tap">点击弹出显示自定义图片的toast</button>
<!-- #endif -->
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="toast1Tap">点击弹出默认toast</button>
<button class="uni-btn-v" type="default" @tap="toastTapIconError">点击弹出设置icon的toast</button>
<button class="uni-btn-v" type="default" @tap="toast2Tap">点击弹出设置duration的toast</button>
<button class="uni-btn-v" type="default" @tap="toast3Tap">点击弹出显示loading的toast</button>
<!-- #ifndef MP-ALIPAY -->
<button class="uni-btn-v" type="default" @tap="toast4Tap">点击弹出显示自定义图片的toast</button>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<button class="uni-btn-v" type="default" @tap="toast5TapTop">点击显示无图标的居顶toast</button>
<button class="uni-btn-v" type="default" @tap="toast5TapCenter">点击显示无图标的居中toast</button>
<button class="uni-btn-v" type="default" @tap="toast5Tap">点击显示无图标的居底toast</button>
<!-- #endif -->
<button class="uni-btn-v" type="default" @tap="hideToast">点击隐藏toast</button>
</view>
<text>{{exeRet}}</text>
</view>
</view>
</template>
<script lang="uts">
export default {
data() {
return {
title: 'toast',
exeRet: ''
}
},
methods: {
toast1Tap: function () {
uni.showToast({
title: "默认",
success:
function (res) {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
function (res) {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toastTapIconError: function () {
uni.showToast({
title: "默认",
icon: 'error',
success:
function (res) {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
function (res) {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toast2Tap: function () {
uni.showToast({
title: "duration 3000",
duration: 3000,
success:
function (res) {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
function (res) {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toast3Tap: function () {
uni.showToast({
title: "loading",
icon: "loading",
duration: 5000,
success:
function (res) {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
function (res) {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toast4Tap: function () {
uni.showToast({
title: "logo",
image: "/static/uni.png",
success:
function (res) {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
function (res) {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
<button class="uni-btn-v" type="default" @tap="toast5TapCenter">点击显示无图标的居中toast</button>
<button class="uni-btn-v" type="default" @tap="toast5Tap">点击显示无图标的居底toast</button>
<!-- #endif -->
<button class="uni-btn-v" type="default" @tap="hideToast">点击隐藏toast</button>
</view>
<text>{{exeRet}}</text>
</view>
</view>
</template>
<script lang="uts">
export default {
data() {
return {
title: 'toast',
exeRet: ''
}
},
methods: {
toast1Tap: function () {
uni.showToast({
title: "默认",
success:
(res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
(res) => {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toastTapIconError: function () {
uni.showToast({
title: "默认",
icon: 'error',
success:
(res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
(res) => {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toast2Tap: function () {
uni.showToast({
title: "duration 3000",
duration: 3000,
success:
(res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
(res) => {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toast3Tap: function () {
uni.showToast({
title: "loading",
icon: "loading",
duration: 5000,
success:
(res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
(res) => {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toast4Tap: function () {
uni.showToast({
title: "logo",
image: "/static/uni.png",
success:
(res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
(res) => {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
// #ifdef APP-PLUS
toast5TapTop: function () {
uni.showToast({
title: "显示一段轻提示",
position: 'top',
success:
function (res)
{
success:
(res) =>
{
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
function (res)
{
fail:
(res) =>
{
this.exeRet = "fail:" + JSON.stringify(res)
},
})
...
...
@@ -107,30 +107,30 @@
uni.showToast({
title: "显示一段轻提示",
position: 'center',
success:
function (res)
{
success:
(res) =>
{
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
function (res)
{
fail:
(res) =>
{
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toast5Tap: function () {
uni.showToast({
title: "显示一段轻提示",
position: 'bottom',
success:
function (res) {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
function (res) {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
// #endif
hideToast: function () {
uni.hideToast()
}
}
}
},
toast5Tap: function () {
uni.showToast({
title: "显示一段轻提示",
position: 'bottom',
success:
(res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:
(res) => {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
// #endif
hideToast: function () {
uni.hideToast()
}
}
}
</script>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录