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