提交 6d189a96 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新 移动uni-navbar-lite到 uni-id-pages-x 里面

上级 4eaf406d
<template>
<view class="uni-navbar">
<view class="uni-navbar-inner" :style="navbarStyle">
<view class="left-content" @click="back">
<text :style="{ color: textColor }" class="uni-icons">{{
unicode
}}</text>
</view>
<view class="uni-navbar-content" :class="{ 'is-left': isLeft }">
<text :style="{ color: textColor }">
<slot>{{ title }}</slot>
</text>
</view>
<view class="right-content">
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
import iconpath from "./uniicons.ttf";
export default {
name: "uni-navbar",
props: {
title: {
type: String,
default: "",
},
isLeft: {
type: Boolean,
default: false,
},
textColor: {
type: String,
default: "#000",
},
},
data() {
return {
statusBarHeight: 0,
};
},
computed: {
navbarStyle() : string {
return `margin-top:${this.statusBarHeight}px`;
},
unicode() : string {
return "\ue600";
},
},
created() {
uni.loadFontFace({
global: false,
family: "UniIconsFontFamily",
source: `url("${iconpath}")`,
success() { },
fail(err) {
console.log(err);
},
});
const sys = uni.getSystemInfoSync();
const statusBarHeight = sys.statusBarHeight;
this.statusBarHeight = statusBarHeight;
},
mounted() {
uni.setNavigationBarColor({
frontColor: "#000000",
backgroundColor: "#ffffff",
});
},
methods: {
back() {
uni.navigateBack({});
},
},
};
</script>
<style>
.uni-icons {
font-family: "UniIconsFontFamily" !important;
font-size: 26px;
font-style: normal;
color: #333;
}
.uni-navbar {
background-color: #fff;
}
.uni-navbar-inner {
position: relative;
flex-direction: row;
justify-content: space-between;
height: 45px;
}
.left-content,
.right-content {
justify-content: center;
<template>
<view class="uni-navbar">
<view class="uni-navbar-inner" :style="navbarStyle">
<view class="left-content" @click="back">
<text :style="{ color: textColor }" class="uni-icons">{{
unicode
}}</text>
</view>
<view class="uni-navbar-content" :class="{ 'is-left': isLeft }">
<text :style="{ color: textColor }">
<slot>{{ title }}</slot>
</text>
</view>
<view class="right-content">
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
import iconpath from "./uniicons.ttf";
export default {
name: "uni-navbar",
props: {
title: {
type: String,
default: "",
},
isLeft: {
type: Boolean,
default: false,
},
textColor: {
type: String,
default: "#000",
},
},
data() {
return {
statusBarHeight: 0,
};
},
computed: {
navbarStyle() : string {
return `margin-top:${this.statusBarHeight}px`;
},
unicode() : string {
return "\ue600";
},
},
created() {
uni.loadFontFace({
global: false,
family: "UniIconsFontFamily",
source: `url("${iconpath}")`,
success() { },
fail(err) {
console.log(err);
},
});
const sys = uni.getSystemInfoSync();
const statusBarHeight = sys.statusBarHeight;
this.statusBarHeight = statusBarHeight;
},
mounted() {
uni.setNavigationBarColor({
frontColor: "#000000",
backgroundColor: "#ffffff",
});
},
methods: {
back() {
uni.navigateBack({});
},
},
};
</script>
<style>
.uni-icons {
font-family: "UniIconsFontFamily" !important;
font-size: 26px;
font-style: normal;
color: #333;
}
.uni-navbar {
background-color: #fff;
}
.uni-navbar-inner {
position: relative;
flex-direction: row;
justify-content: space-between;
height: 45px;
}
.left-content,
.right-content {
justify-content: center;
align-items: center;
width: 18%;
height: 100%;
}
.uni-navbar-content {
position: absolute;
height: 100%;
top: 0;
bottom: 0;
left: 45px;
right: 45px;
flex-direction: row;
justify-content: center;
align-items: center;
}
.is-left {
justify-content: flex-start;
}
height: 100%;
}
.uni-navbar-content {
position: absolute;
height: 100%;
top: 0;
bottom: 0;
left: 45px;
right: 45px;
flex-direction: row;
justify-content: center;
align-items: center;
}
.is-left {
justify-content: flex-start;
}
</style>
<template>
<view class="uni-navbar">
<view class="uni-navbar-inner" :style="navbarStyle">
<view class="left-content" @click="back">
<text class="uni-icons uniui-back"></text>
</view>
<view class="uni-navbar-content">
<slot>{{title}}</slot>
</view>
<view class="right-content">
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
export default {
name: "uni-navbar",
props: {
title: {
type: String,
default: ''
}
},
data() {
return {
statusBarHeight: 0
};
},
computed: {
navbarStyle() {
return `margin-top:${this.statusBarHeight}px`
},
},
created() {
const sys = uni.getSystemInfoSync()
const statusBarHeight = sys.statusBarHeight
this.statusBarHeight = statusBarHeight
},
methods: {
back() {
uni.navigateBack({})
}
},
}
</script>
<style>
@import './uni-icons.css';
.uni-icons {
font-family: UniIconsLight;
text-decoration: none;
text-align: center;
font-size: 22px;
font-style: normal;
color: #333;
}
.uni-navbar {
border: 1px #eee solid;
background-color: #fff;
}
.uni-navbar-inner {
position: relative;
flex-direction: row;
justify-content: space-between;
height: 45px;
}
.left-content,
.right-content {
justify-content: center;
align-items: center;
width: 45px;
height: 100%;
}
.uni-navbar-content {
position: absolute;
height: 100%;
top: 0;
bottom: 0;
left: 45px;
right: 45px;
justify-content: center;
align-items: center;
}
<template>
<view class="uni-navbar">
<view class="uni-navbar-inner" :style="navbarStyle">
<view class="left-content" @click="back">
<text class="uni-icons uniui-back"></text>
</view>
<view class="uni-navbar-content">
<slot>{{title}}</slot>
</view>
<view class="right-content">
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
export default {
name: "uni-navbar",
props: {
title: {
type: String,
default: ''
}
},
data() {
return {
statusBarHeight: 0
};
},
computed: {
navbarStyle() {
return `margin-top:${this.statusBarHeight}px`
},
},
created() {
const sys = uni.getSystemInfoSync()
const statusBarHeight = sys.statusBarHeight
this.statusBarHeight = statusBarHeight
},
methods: {
back() {
uni.navigateBack({})
}
},
}
</script>
<style>
@import './uni-icons.css';
.uni-icons {
font-family: UniIconsLight;
text-decoration: none;
text-align: center;
font-size: 22px;
font-style: normal;
color: #333;
}
.uni-navbar {
border: 1px #eee solid;
background-color: #fff;
}
.uni-navbar-inner {
position: relative;
flex-direction: row;
justify-content: space-between;
height: 45px;
}
.left-content,
.right-content {
justify-content: center;
align-items: center;
width: 45px;
height: 100%;
}
.uni-navbar-content {
position: absolute;
height: 100%;
top: 0;
bottom: 0;
left: 45px;
right: 45px;
justify-content: center;
align-items: center;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册