1234567891011121314151617181920212223242526272829303132 |
- import { VueLikePage } from '../../utils/page'
- import displayApi from '../../apis/exhibition'
- VueLikePage([], {
- data: {
- },
- methods: {
- onLoad () {
- displayApi.getExhibitionDetail().then(res => {
- this.setData({
- html: this.formatImg(res.data.contactUs)
- })
- })
- },
- formatImg: function (html) {
- var newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
- let processed=null;
- //如果原img标签不存在style属性值
- if(!match.match(/style=\"(.*)\"/gi)){
- processed=match.replace(/\<img/g, '<img style="width:100%;height:auto;display:block"');
- }else{
- processed = match.replace(/style=\"(.*)\"/gi, 'style="width:100%;height:auto;display:block"');
- }
-
- return processed;
- })
- return newContent;
- },
- collect (e) {
- }
- }
- })
|