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
6f8886fe
Commit
6f8886fe
authored
May 22, 2026
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
7ada8ee0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
11 deletions
+41
-11
newsInDetail.vue
pages/kotra/newsInDetail.vue
+41
-11
No files found.
pages/kotra/newsInDetail.vue
View file @
6f8886fe
...
@@ -60,7 +60,8 @@
...
@@ -60,7 +60,8 @@
</view>
</view>
<view
class=
"acdetaiWriter"
>
<view
class=
"acdetaiWriter"
>
<view>
<view>
<u-tag
v-if=
"dataList&&dataList.Industry"
:text=
"dataList.Industry"
type=
"primary"
style=
"margin-right: 12px;"
></u-tag>
<u-tag
v-if=
"dataList&&dataList.Industry"
:text=
"dataList.Industry"
type=
"primary"
style=
"margin-right: 12px;"
></u-tag>
<text>
<text>
<
template
v-if=
"dataList&&dataList.PublishTimeStr"
>
<
template
v-if=
"dataList&&dataList.PublishTimeStr"
>
{{
dataList
.
PublishTimeStr
}}
{{
dataList
.
PublishTimeStr
}}
...
@@ -85,7 +86,7 @@
...
@@ -85,7 +86,7 @@
},
},
dataList
:
{},
dataList
:
{},
richtext
:
''
,
richtext
:
''
,
mainColor
:
''
mainColor
:
''
}
}
},
},
created
()
{},
created
()
{},
...
@@ -106,12 +107,41 @@
...
@@ -106,12 +107,41 @@
},
},
(
res
)
=>
{
(
res
)
=>
{
if
(
res
.
resultCode
==
1
)
{
if
(
res
.
resultCode
==
1
)
{
this
.
dataList
=
res
.
data
this
.
dataList
=
res
.
data
;
this
.
richtext
=
this
.
dataList
.
NewsInfo
.
replace
(
/<img
[^
>
]
*>/gi
,
function
(
match
,
capture
)
{
let
html
=
this
.
dataList
.
NewsInfo
var
match
=
match
.
replace
(
/style=
\"(
.*
)\"
/gi
,
'style="max-width:100% !important"'
);
// 1. 处理图片:强制 max-width:100% (你原有的逻辑)
return
match
;
html
=
html
.
replace
(
/<img
[^
>
]
*>/gi
,
function
(
match
)
{
return
match
.
replace
(
/style=
\"(
.*
)\"
/gi
,
'style="max-width:100% !important; height:auto;"'
);
});
// 2. 处理 table:强制宽度 100%,并移除固定 width 属性
html
=
html
.
replace
(
/<table
[^
>
]
*>/gi
,
function
(
match
)
{
// 先移除原有的 width 属性(可能是 width="657" 或 width="100%")
let
newMatch
=
match
.
replace
(
/
\s
*width
\s
*=
\s
*
[
"'
][^
"'
]
*
[
"'
]
/gi
,
''
);
// 再处理 style,添加或覆盖 width:100%
if
(
/style
\s
*=
\s
*
[
"'
][^
"'
]
*
[
"'
]
/i
.
test
(
newMatch
))
{
// 已有 style 属性,添加 width:100%
newMatch
=
newMatch
.
replace
(
/style
\s
*=
\s
*
[
"'
]([^
"'
]
*
)[
"'
]
/i
,
function
(
styleMatch
,
styleContent
)
{
// 如果 style 中已有 width,先移除
styleContent
=
styleContent
.
replace
(
/width
\s
*:
[^
;
]
+;
?
/gi
,
''
);
return
`style="
${
styleContent
}
; width:100%;"`
;
});
});
}
else
{
// 没有 style 属性,直接添加
newMatch
=
newMatch
.
replace
(
/<table/
,
'<table style="width:100%;"'
);
}
return
newMatch
;
});
this
.
richtext
=
html
;
// this.richtext = this.dataList.NewsInfo.replace(/
<
img
[
^>
]
*>
/gi, function
(
match, capture
)
{
// var match = match.replace(/style=\"(.*)\"/gi,
// 'style="max-width:100% !important"');
// return match;
// });
}
}
}
}
);
);
...
...
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