提交 e3b23a49 编写于 作者: 芊里

小程序标题栏作用域修改

上级 eaf5e117
...@@ -6,25 +6,27 @@ ...@@ -6,25 +6,27 @@
unicloud-db 组件文档:https://uniapp.dcloud.net.cn/uniCloud/unicloud-db-component unicloud-db 组件文档:https://uniapp.dcloud.net.cn/uniCloud/unicloud-db-component
DB Schema 规范:https://uniapp.dcloud.net.cn/uniCloud/schema DB Schema 规范:https://uniapp.dcloud.net.cn/uniCloud/schema
--> -->
<view class="article"> <view class="article">
<uni-nav-bar :statusBar="true" :border="false"></uni-nav-bar> <!-- #ifdef APP-PLUS -->
<uni-nav-bar :statusBar="true" :border="false"></uni-nav-bar>
<!-- #endif -->
<view class="article-title">{{ title }}</view>
<unicloud-db v-slot:default="{data, loading, error, options}" :options="formData" :collection="collection" <unicloud-db v-slot:default="{data, loading, error, options}" :options="formData" :collection="collection"
:field="field" :getone="true" :where="where" :manual="true" ref="detail" :field="field" :getone="true" :where="where" :manual="true" ref="detail"
foreignKey="opendb-news-articles.author" @load="loadData"> foreignKey="opendb-news-articles.author" @load="loadData">
<template v-if="!loading && data"> <template v-if="!loading && data">
<view class="article-title">{{title}}</view>
<uni-list :border="false"> <uni-list :border="false">
<uni-list-item thumbSize="lg" :thumb="data.image"> <uni-list-item thumbSize="lg" :thumb="data.image">
<!-- 通过body插槽定义作者信息内容 --> <!-- 通过body插槽定义作者信息内容 -->
<view slot="body" class="header-content"> <view slot="body" class="header-content">
<view class="uni-title">{{data.author && data.author[0].username}}</view> <view class="uni-title">{{data.author && data.author[0].username}}</view>
<view class="uni-note">更新于
<uni-dateformat :date="data.last_modify_date" format="yyyy-MM-dd"
:threshold="[60000, 2592000000]" />
</view>
</view> </view>
<view slot="footer" class="footer"> <view slot="footer" class="footer">
<button @click="followClick" class="footer-button">关注</button> <view class="uni-note">更新于
<uni-dateformat :date="data.last_modify_date" format="yyyy-MM-dd hh:mm"
:threshold="[60000, 2592000000]" />
</view>
<!-- <button @click="followClick" class="footer-button">关注</button> -->
</view> </view>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
...@@ -61,7 +63,7 @@ ...@@ -61,7 +63,7 @@
return { return {
// 当前显示 _id // 当前显示 _id
id: "", id: "",
title: '', title: 'title',
// 数据表名 // 数据表名
collection: 'opendb-news-articles,uni-id-users', collection: 'opendb-news-articles,uni-id-users',
// 查询字段,多个字段用 , 分割 // 查询字段,多个字段用 , 分割
...@@ -92,7 +94,7 @@ ...@@ -92,7 +94,7 @@
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: event.title title: event.title
}) })
} }
}, },
onNavigationBarButtonTap(event) { onNavigationBarButtonTap(event) {
if (event.type == 'share') { if (event.type == 'share') {
...@@ -145,6 +147,7 @@ ...@@ -145,6 +147,7 @@
}, },
loadData(data) { loadData(data) {
console.log(data);
//如果上一页未传递标题过来(如搜索直达详情),则从新闻详情中读取标题 //如果上一页未传递标题过来(如搜索直达详情),则从新闻详情中读取标题
if (this.title == '' && data[0].title) { if (this.title == '' && data[0].title) {
this.title = data[0].title this.title = data[0].title
...@@ -153,6 +156,7 @@ ...@@ -153,6 +156,7 @@
}); });
} }
console.log(this.title);
this.setFavorite(); this.setFavorite();
}, },
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册