mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-14 21:36:45 +08:00
fix: titlebar 文字无法居中的问题
This commit is contained in:
@@ -1,130 +1,135 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="top" :class="[sticky ? 'sticky': '']">
|
<view class="top" :class="[sticky ? 'sticky': '']">
|
||||||
<view v-show="showBack" class="top-back" @click="toBack()">
|
<view v-show="showBack" class="top-back" @click="toBack()">
|
||||||
<!-- <u-icon color="#333" size="20" name="arrow-left"></u-icon>-->
|
<!-- <u-icon color="#333" size="20" name="arrow-left"></u-icon>-->
|
||||||
<
|
<
|
||||||
</view>
|
</view>
|
||||||
<view class="top-title"><slot></slot></view>
|
<view class="top-title">
|
||||||
<view @click="topgae()" style="color: #387DF7;">
|
<slot></slot>
|
||||||
<slot name="right"></slot>
|
</view>
|
||||||
</view>
|
<view @click="topgae()" style="color: #387DF7;">
|
||||||
</view>
|
<slot name="right"></slot>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props:{
|
props: {
|
||||||
backUrl:{
|
backUrl: {
|
||||||
type:String,
|
type: String,
|
||||||
default:''
|
default: ''
|
||||||
},
|
},
|
||||||
showBack:{
|
showBack: {
|
||||||
type:Boolean,
|
type: Boolean,
|
||||||
default:false
|
default: false
|
||||||
},
|
},
|
||||||
goPgae:{
|
goPgae: {
|
||||||
type:String,
|
type: String,
|
||||||
default:''
|
default: ''
|
||||||
},
|
},
|
||||||
// 启用粘性滚动
|
// 启用粘性滚动
|
||||||
sticky: {
|
sticky: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
topgae() {
|
||||||
|
if (this.goPgae != '') {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: this.goPgae
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
toBack() {
|
||||||
return {
|
// 如果定义的有 go 事件,优先处理这个
|
||||||
|
if (this.$listeners['go']) {
|
||||||
}
|
this.$emit('go')
|
||||||
},
|
return
|
||||||
methods: {
|
}
|
||||||
topgae() {
|
if (this.backUrl != '') {
|
||||||
if(this.goPgae!=''){
|
if (this.backUrl == '/pages/my/index') {
|
||||||
uni.navigateTo({
|
uni.switchTab({
|
||||||
url:this.goPgae
|
url: this.backUrl
|
||||||
});
|
})
|
||||||
}
|
} else {
|
||||||
},
|
uni.navigateTo({
|
||||||
toBack(){
|
url: this.backUrl
|
||||||
// 如果定义的有 go 事件,优先处理这个
|
});
|
||||||
if( this.$listeners['go'] ) {
|
|
||||||
this.$emit('go')
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if(this.backUrl!=''){
|
} else {
|
||||||
if(this.backUrl == '/pages/my/index'){
|
let pages = getCurrentPages();
|
||||||
uni.switchTab({
|
//console.log(pages);
|
||||||
url:this.backUrl
|
const prevPage = pages[pages.length - 2];
|
||||||
})
|
if (!prevPage) {
|
||||||
}else{
|
uni.switchTab({
|
||||||
uni.navigateTo({
|
url: '/pages/index/index'
|
||||||
url:this.backUrl
|
})
|
||||||
});
|
} else {
|
||||||
}
|
uni.navigateBack();
|
||||||
}else{
|
}
|
||||||
let pages =getCurrentPages();
|
}
|
||||||
//console.log(pages);
|
}
|
||||||
const prevPage=pages[pages.length-2];
|
}
|
||||||
if(!prevPage){
|
}
|
||||||
uni.switchTab({
|
|
||||||
url:'/pages/index/index'
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
uni.navigateBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.top{
|
.top {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
// justify-content: space-between;
|
justify-content: space-between;
|
||||||
.top-back{
|
position: relative;
|
||||||
color: #333;
|
|
||||||
//padding-top:10px;
|
|
||||||
height: 40px;
|
|
||||||
line-height: 40px;
|
|
||||||
padding-left: 15px;
|
|
||||||
}
|
|
||||||
.top-title{
|
|
||||||
text-align: center;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 550;
|
|
||||||
color: #333;
|
|
||||||
height: 40px;
|
|
||||||
text-align: center;
|
|
||||||
width: 80%;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
line-height: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.sticky {
|
.top-back {
|
||||||
position: sticky;
|
color: #333;
|
||||||
top: 0;
|
//padding-top:10px;
|
||||||
//防止其他元素遮盖
|
height: 40px;
|
||||||
z-index: 99;
|
line-height: 40px;
|
||||||
}
|
padding-left: 15px;
|
||||||
}
|
}
|
||||||
// .arrow:before {
|
|
||||||
// content: " ";
|
.top-title {
|
||||||
// display: inline-block;
|
width: 100%;
|
||||||
// -webkit-transform: rotate(45deg);
|
text-align: center;
|
||||||
// -ms-transform: rotate(45deg);
|
position: absolute;
|
||||||
// transform: rotate(45deg);
|
font-size: 16px;
|
||||||
// height: .5rem;
|
font-weight: 550;
|
||||||
// width: .5rem;
|
color: #333;
|
||||||
// border-width: 0 0 2px 2px;
|
height: 40px;
|
||||||
// border-color: #FFFFFF;
|
|
||||||
// border-style: solid;
|
white-space: nowrap;
|
||||||
// position: relative;
|
overflow: hidden;
|
||||||
// top: 0
|
text-overflow: ellipsis;
|
||||||
// }
|
line-height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.sticky {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
//防止其他元素遮盖
|
||||||
|
z-index: 99;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// .arrow:before {
|
||||||
|
// content: " ";
|
||||||
|
// display: inline-block;
|
||||||
|
// -webkit-transform: rotate(45deg);
|
||||||
|
// -ms-transform: rotate(45deg);
|
||||||
|
// transform: rotate(45deg);
|
||||||
|
// height: .5rem;
|
||||||
|
// width: .5rem;
|
||||||
|
// border-width: 0 0 2px 2px;
|
||||||
|
// border-color: #FFFFFF;
|
||||||
|
// border-style: solid;
|
||||||
|
// position: relative;
|
||||||
|
// top: 0
|
||||||
|
// }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user