Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mallapp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
mallapp
Commits
c5f5ba4c
Commit
c5f5ba4c
authored
Jun 01, 2026
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
6f8886fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
newsInDetail.vue
pages/kotra/newsInDetail.vue
+20
-3
No files found.
pages/kotra/newsInDetail.vue
View file @
c5f5ba4c
...
@@ -71,6 +71,7 @@
...
@@ -71,6 +71,7 @@
</view>
</view>
</view>
</view>
<view
class=
"acdetailBottom"
>
<view
class=
"acdetailBottom"
>
<!-- <rich-text class="newsInDetail_Intro" :nodes="richtext"></rich-text> -->
<view
class=
"newsInDetail_Intro"
v-html=
"richtext"
></view>
<view
class=
"newsInDetail_Intro"
v-html=
"richtext"
></view>
</view>
</view>
</view>
</view>
...
@@ -109,10 +110,26 @@
...
@@ -109,10 +110,26 @@
if
(
res
.
resultCode
==
1
)
{
if
(
res
.
resultCode
==
1
)
{
this
.
dataList
=
res
.
data
;
this
.
dataList
=
res
.
data
;
let
html
=
this
.
dataList
.
NewsInfo
let
html
=
this
.
dataList
.
NewsInfo
console
.
log
(
"html"
,
html
);
// 1. 处理图片:
强制 max-width:100% (你原有的逻辑)
// 1. 处理图片:
优先使用 data-src(懒加载原图),同时强制 max-width:100%
html
=
html
.
replace
(
/<img
[^
>
]
*>/gi
,
function
(
match
)
{
html
=
html
.
replace
(
/<img
[^
>
]
*>/gi
,
function
(
match
)
{
return
match
.
replace
(
/style=
\"(
.*
)\"
/gi
,
// 优先使用 data-src 的图片地址
const
dataSrcMatch
=
match
.
match
(
/data-src=
[
"'
]([^
"'
]
+
)[
"'
]
/
);
if
(
dataSrcMatch
)
{
const
originalUrl
=
dataSrcMatch
[
1
];
// 移除懒加载参数(tp=webp, wxfrom=5, wx_lazy=1, imgIndex)
const
cleanUrl
=
originalUrl
.
replace
(
/&tp=webp/gi
,
''
)
.
replace
(
/&wxfrom=
\d
+/gi
,
''
)
.
replace
(
/&wx_lazy=
\d
+/gi
,
''
)
.
replace
(
/#imgIndex=
\d
+/gi
,
''
);
// 移除原有的 src 属性,替换为干净的 data-src
match
=
match
.
replace
(
/
\s
*src=
[
"'
][^
"'
]
*
[
"'
]
/gi
,
''
);
match
=
match
.
replace
(
/
\s
*data-src=
[
"'
][^
"'
]
*
[
"'
]
/gi
,
''
);
return
`<img src="
${
cleanUrl
}
" style="max-width:100% !important;height:auto;display:block;" />`
;
}
// 如果没有 data-src,只处理已有的 src
return
match
.
replace
(
/style="
(
.*
)
"/gi
,
'style="max-width:100% !important; height:auto;"'
);
'style="max-width:100% !important; height:auto;"'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment