123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- <template>
- <view>
- <uni-nav-bar color="#ffffff" background-color="#007AFF" :status-bar="true" left-icon="arrowleft" left-text="返回" title="标题" @clickLeft="back" />
- <text class="example-info">本导航栏为自定义组件,并非原生导航栏。除非原生导航栏无法满足需求,否则不推荐使用自定义导航栏组件。具体参考https://ask.dcloud.net.cn/article/34921</text>
- <uni-section title="基本用法" type="line"></uni-section>
- <view class="example-body">
- <uni-nav-bar left-icon="arrowleft" title="标题" @clickLeft="back" />
- </view>
- <uni-section title="左右显示文字" type="line"></uni-section>
- <view class="example-body">
- <uni-nav-bar left-icon="arrowleft" right-text="菜单" left-text="返回" title="标题" @clickLeft="back" />
- </view>
- <uni-section title="插入slot" type="line"></uni-section>
- <view class="example-body">
- <uni-nav-bar :fixed="false" color="#333333" background-color="#FFFFFF" right-icon="scan" @clickLeft="showCity" @clickRight="scan">
- <block slot="left">
- <view class="city">
- <view><text class="uni-nav-bar-text">{{ city }}</text></view>
- <uni-icons type="arrowdown" color="#333333" size="22" />
- </view>
- </block>
- <view class="input-view">
- <uni-icons class="input-uni-icon" type="search" size="22" color="#666666" />
- <input confirm-type="search" class="nav-bar-input" type="text" placeholder="输入搜索关键词" @confirm="confirm">
- </view>
- </uni-nav-bar>
- </view>
- </view>
- </template>
- <script>
- export default {
- components: {},
- data() {
- return {
- city: '北京'
- }
- },
- methods: {
- back() {
- uni.navigateBack({
- delta: 1
- })
- },
- showMenu() {
- uni.showToast({
- title: '菜单'
- })
- },
- clickLeft() {
- uni.showToast({
- title: '左侧按钮'
- })
- },
- search() {
- uni.showToast({
- title: '搜索'
- })
- },
- showCity() {
- uni.showToast({
- title: '选择城市'
- })
- },
- scan() {
- uni.showToast({
- title: '扫码'
- })
- },
- confirm() {
- uni.showToast({
- title: '搜索'
- })
- }
- },
- onPullDownRefresh() {
- console.log('onPullDownRefresh')
- setTimeout(function() {
- uni.stopPullDownRefresh()
- console.log('stopPullDownRefresh')
- }, 1000)
- }
- }
- </script>
- <style>
- @charset "UTF-8";
- /* 头条小程序组件内不能引入字体 */
- /* #ifdef MP-TOUTIAO */
- @font-face {
- font-family: uniicons;
- font-weight: normal;
- font-style: normal;
- src: url("~@/static/uni.ttf") format("truetype");
- }
- /* #endif */
- /* #ifndef APP-NVUE */
- page {
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- background-color: #efeff4;
- min-height: 100%;
- height: auto;
- }
- view {
- font-size: 14px;
- line-height: inherit;
- }
- .example {
- padding: 0 15px 15px;
- }
- .example-info {
- padding: 15px;
- color: #3b4144;
- background: #ffffff;
- }
- .example-body {
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: center;
- padding: 0;
- font-size: 14px;
- background-color: #ffffff;
- }
- /* #endif */
- .example {
- padding: 0 15px;
- }
- .example-info {
- /* #ifndef APP-NVUE */
- display: block;
- /* #endif */
- padding: 15px;
- color: #3b4144;
- background-color: #ffffff;
- font-size: 14px;
- line-height: 20px;
- }
- .example-info-text {
- font-size: 14px;
- line-height: 20px;
- color: #3b4144;
- }
- .example-body {
- flex-direction: column;
- padding: 15px;
- background-color: #ffffff;
- }
- .word-btn-white {
- font-size: 18px;
- color: #FFFFFF;
- }
- .word-btn {
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: row;
- align-items: center;
- justify-content: center;
- border-radius: 6px;
- height: 48px;
- margin: 15px;
- background-color: #007AFF;
- }
- .word-btn--hover {
- background-color: #4ca2ff;
- }
- .uni-nav-bar-text {
- font-size: 14px;
- }
- .city {
- /* #ifndef APP-PLUS-NVUE */
- display: flex;
- /* #endif */
- flex-direction: row;
- align-items: center;
- justify-content: flex-start;
- margin-left: 4px;
- }
- .input-view {
- /* #ifndef APP-PLUS-NVUE */
- display: flex;
- /* #endif */
- flex-direction: row;
- flex: 1;
- background-color: #f8f8f8;
- height: 30px;
- border-radius: 15px;
- padding: 0 15px;
- flex-wrap: nowrap;
- margin: 7px 0;
- line-height: 30px;
- }
- .input-uni-icon {
- line-height: 30px;
- }
- .nav-bar-input {
- height: 30px;
- line-height: 30px;
- /* #ifdef APP-PLUS-NVUE */
- width: 370rpx;
- /* #endif */
- padding: 0 5px;
- font-size: 14px;
- background-color: #f8f8f8;
- }
- .example-body {
- /* #ifndef APP-NVUE */
- display: block;
- /* #endif */
- padding: 0;
- }
- </style>
|