个人中心账号复制,切换tab页面时报错
This commit is contained in:
parent
b512eac708
commit
77fb6acc2d
|
|
@ -1,17 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="user-info flex px-[50rpx] justify-between py-[50rpx]">
|
<view class="user-info flex px-[50rpx] justify-between py-[50rpx]">
|
||||||
<navigator
|
<view
|
||||||
v-if="isLogin"
|
v-if="isLogin"
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
hover-class="none"
|
@click="navigateTo('/pages/user_data/user_data')"
|
||||||
url="/pages/user_data/user_data"
|
|
||||||
>
|
>
|
||||||
<u-avatar :src="user.avatar" :size="120"></u-avatar>
|
<u-avatar :src="user.avatar" :size="120"></u-avatar>
|
||||||
<view class="text-white ml-[20rpx]">
|
<view class="text-white ml-[20rpx]">
|
||||||
<view class="text-2xl">{{ user.nickname }}</view>
|
<view class="text-2xl">{{ user.nickname }}</view>
|
||||||
<view class="text-xs mt-[18rpx]">账号:{{ user.username }}</view>
|
<view class="text-xs mt-[18rpx]" @click.stop="copy(user.username)">
|
||||||
|
账号:{{ user.username }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</navigator>
|
|
||||||
<navigator v-else class="flex items-center" hover-class="none" url="/pages/login/login">
|
<navigator v-else class="flex items-center" hover-class="none" url="/pages/login/login">
|
||||||
<u-avatar src="/static/images/user/default_avatar.png" :size="120"></u-avatar>
|
<u-avatar src="/static/images/user/default_avatar.png" :size="120"></u-avatar>
|
||||||
<view class="text-white text-3xl ml-[20rpx]">未登录</view>
|
<view class="text-white text-3xl ml-[20rpx]">未登录</view>
|
||||||
|
|
@ -22,6 +23,8 @@
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { useCopy } from '@/hooks/useCopy'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
content: {
|
content: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
@ -39,6 +42,12 @@ const props = defineProps({
|
||||||
type: Boolean
|
type: Boolean
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const { copy } = useCopy()
|
||||||
|
const navigateTo = (url: string) => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
export function useCopy() {
|
||||||
|
const copy = (text: string) => {
|
||||||
|
uni.setClipboardData({
|
||||||
|
data: String(text)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
copy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -245,9 +245,9 @@ export default {
|
||||||
if(pagePath == this.pageUrl || pagePath == "/" + this.pageUrl) return
|
if(pagePath == this.pageUrl || pagePath == "/" + this.pageUrl) return
|
||||||
// 发出事件和修改v-model绑定的值
|
// 发出事件和修改v-model绑定的值
|
||||||
this.$emit("change", index);
|
this.$emit("change", index);
|
||||||
uni.switchTab({
|
// uni.switchTab({
|
||||||
url: pagePath
|
// url: pagePath
|
||||||
});
|
// });
|
||||||
} else {
|
} else {
|
||||||
// 如果配置了papgePath属性,将不会双向绑定v-model传入的value值
|
// 如果配置了papgePath属性,将不会双向绑定v-model传入的value值
|
||||||
// 因为这个模式下,不再需要v-model绑定的value值了,而是通过getCurrentPages()适配
|
// 因为这个模式下,不再需要v-model绑定的value值了,而是通过getCurrentPages()适配
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue