detail.vue 984 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <view class="page">
  3. <rich-text :nodes="info.content ? getHtml(info.content) : ''" space="true" selectable="true"/>
  4. </view>
  5. </template>
  6. <script>
  7. import htmlParser from '../../common/html-parser';
  8. import _get from '../../common/_get';
  9. export default {
  10. components: {
  11. },
  12. data() {
  13. return {
  14. id:0,
  15. info: {
  16. content:''
  17. }, // 页面数据
  18. noData: '<p style="text-align:center;color:#666">详情加载中...</p>',
  19. }
  20. },
  21. onLoad(options) {
  22. // 初始化页面数据
  23. if('id' in options){
  24. this.id = options.id
  25. }
  26. this.getDetail();
  27. },
  28. methods: {
  29. /**
  30. * 请求页面数据
  31. */
  32. getDetail(){
  33. let _this = this;
  34. _get.getArticleDetail({article_id:this.id},function (ret) {
  35. _this.info = ret;
  36. uni.setNavigationBarTitle({
  37. title: ret.article_name,
  38. });
  39. });
  40. },
  41. getHtml(content){
  42. return htmlParser(content);
  43. },
  44. }
  45. }
  46. </script>
  47. <style>
  48. .page image{
  49. max-width: 100%;
  50. }
  51. </style>