feat: 初始化
This commit is contained in:
57
components/PageTitle/PageTitle.vue
Normal file
57
components/PageTitle/PageTitle.vue
Normal file
@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<view class="titleWrapper" @click="back">
|
||||
<image src="/static/backIcon.png" mode="aspectFit" class="titleIcon"></image>
|
||||
<text class="titleText" :style="{ letterSpacing: letterSpacing ?? '' }">{{ title }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'PageTitle',
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ''
|
||||
},
|
||||
backTarget: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ''
|
||||
},
|
||||
onBack: {
|
||||
type: Function,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
letterSpacing: undefined
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
if (this.onBack) {
|
||||
this.onBack();
|
||||
}
|
||||
if (this.backTarget) {
|
||||
uni.redirectTo({ url: this.backTarget });
|
||||
} else {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const locale = uni.getLocale();
|
||||
if (['zh-CN', 'zh-TW'].includes(locale)) {
|
||||
this.letterSpacing = '2px';
|
||||
} else {
|
||||
this.letterSpacing = undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './index.scss';
|
||||
</style>
|
20
components/PageTitle/index.scss
Normal file
20
components/PageTitle/index.scss
Normal file
@ -0,0 +1,20 @@
|
||||
.titleWrapper {
|
||||
display: flex;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: rgba(51, 51, 51, 1);
|
||||
cursor: pointer;
|
||||
.titleIcon {
|
||||
width: 23px;
|
||||
height: 23px;
|
||||
margin-top: 9px;
|
||||
flex-shrink: 0;
|
||||
margin-right: 11px;
|
||||
}
|
||||
.titleText {
|
||||
word-break: break-all;
|
||||
line-height: 41px;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user