article.vue 901 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view class="article">
  3. <u-parse :content="content"></u-parse>
  4. </view>
  5. </template>
  6. <script>
  7. import {getNewsRead} from "@/common/api/news.js";
  8. export default {
  9. data() {
  10. return {
  11. id: "",
  12. content: undefined,
  13. };
  14. },
  15. onLoad(options) {
  16. uni.hideShareMenu({});
  17. if (options.id) {
  18. this.id = options.id;
  19. this.getData();
  20. }
  21. },
  22. methods: {
  23. getData() {
  24. const data = {
  25. name: this.name,
  26. };
  27. getNewsRead({
  28. id: this.id,
  29. }).then(({data = {}}) => {
  30. uni.setNavigationBarTitle({
  31. title: data.name,
  32. });
  33. this.content = data.content;
  34. });
  35. },
  36. },
  37. };
  38. </script>
  39. <style lang="scss" scoped>
  40. .article {
  41. width: 100%;
  42. display: flex;
  43. align-items: center;
  44. flex-direction: column;
  45. padding: 20rpx 20rpx 40rpx;
  46. box-sizing: border-box;
  47. text-align: justify;
  48. }
  49. </style>