拓恒河湖长制全民护河平台WEB端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1KB

  1. // package_first/pages/announceDetail/index.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. dataSource: {}
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad(options) {
  13. if(options) {
  14. const dataSource = JSON.parse(decodeURIComponent(options.data))
  15. let imgs=dataSource.content.match(/<img.*?src="(.*)".*?\/>/g);
  16. if(!imgs){
  17. this.setData({dataSource})
  18. } else {
  19. for(let img of imgs){
  20. let temp
  21. temp=img.replace(/(width=".*?"|height=".*?")/g,"");
  22. if(/style="(.*?)"/.test(temp)){
  23. temp=temp.replace(RegExp.$1,RegExp.$1+"width:100% !important;height:auto;display:block")
  24. }else{
  25. temp=temp.replace(/<img/,"<img style='width:100% !important;height:auto;display:block'")
  26. }
  27. dataSource.content=dataSource.content.replace(img,temp)
  28. }
  29. this.setData({dataSource})
  30. }
  31. }
  32. }
  33. })