46 lines
1.1 KiB
Vue
46 lines
1.1 KiB
Vue
<!-- 纯富文本展示页 -->
|
||
<template>
|
||
<view>
|
||
<u-parse :html="content"></u-parse>
|
||
<Loading :show="loading" />
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data(){
|
||
return{
|
||
content: '',
|
||
loading: true,// 加载
|
||
}
|
||
},
|
||
methods:{
|
||
async getArticle(moduleName,labelName){
|
||
try{
|
||
this.loading = true;
|
||
let articleRes = await this.$api.getArticleList({
|
||
labelName: labelName,
|
||
moduleName: moduleName,
|
||
size: 1,
|
||
current: 1,
|
||
});
|
||
if(articleRes?.success){
|
||
this.content = articleRes.data?.records[0].text;
|
||
// 下面实际是为了增加浏览量,因为直接根据id查询结果是错误的,只能通过这种方式实现,具体逻辑不好理解,想知道为什么可以问后端
|
||
this.$api.getSingleArticle(articleRes.data?.records[0].id);
|
||
}
|
||
}catch(e){
|
||
}finally{
|
||
this.loading = false;
|
||
}
|
||
}
|
||
},
|
||
async onLoad(options) {
|
||
if(options.title) await uni.setNavigationBarTitle({title: options.title});
|
||
this.getArticle(options.moduleName,options.title);
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
</style> |