index.vue 974 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <view>
  3. <mp-html :content="detail.content" />
  4. </view>
  5. </template>
  6. <script>
  7. import mpHtml from '@/uni_modules/mp-html/components/mp-html/mp-html'
  8. export default {
  9. components: {
  10. mpHtml
  11. },
  12. data(){
  13. return{
  14. detail:{}
  15. }
  16. },
  17. onLoad(e) {
  18. uni.setNavigationBarColor({
  19. frontColor: '#ffffff',
  20. backgroundColor: this.$store.state.color,
  21. })
  22. this.http(e.id);
  23. },
  24. methods:{
  25. http(id){
  26. this.$http.request('yy/article_detail', {
  27. id,
  28. }).then(res => {
  29. if (res.code == "200") {
  30. if(res.data.content){
  31. res.data.content = res.data.content.replace(/\<img/gi,
  32. '<img style="max-width:100%;height:auto" ')
  33. }
  34. uni.setNavigationBarTitle({
  35. title:res.data.title
  36. })
  37. this.detail = res.data
  38. }
  39. }).catch((res) => {
  40. // console.log(res, "666")
  41. uni.showToast({
  42. title: res.message,
  43. icon: 'none'
  44. })
  45. });
  46. }
  47. }
  48. }
  49. </script>
  50. <style>
  51. </style>