Skip to content

Commit

Permalink
Merge pull request #5 from tourze/patch-3
Browse files Browse the repository at this point in the history
兼容a标签内嵌img标签时,点击onClick不触发的问题
  • Loading branch information
ShaoGongBra authored Dec 7, 2022
2 parents d7dcc1d + ca16f61 commit 06c201d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions components/HtmlView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ const View = ({
// 是否是纯文本组件
const isTextComp = useMemo(() => !isText && children?.every?.(item => item?.props?.nodeName === 'Text'), [isText, children])

//console.log('View', href, isText);
// console.log('View', props, isText);
return isText ? (
<TextPlatform
style={viewStyle}
className={className}
onClick={() => {
// 一般 a 链接才有这个
if (props.href && isText) {
if (props.href) {
onClick({ type: 'link', ...props });
}
}}
Expand All @@ -113,7 +113,16 @@ const View = ({
) :
isTextComp ?
<TextPlatform style={textStyle} className={className}>{children}</TextPlatform> :
<TaroView style={viewStyle} className={className}>
<TaroView
style={viewStyle}
className={className}
onClick={() => {
// 一般 a 链接才有这个
if (props.href) {
onClick({ type: 'link', ...props });
}
}}
>
{
children?.map?.((item, index) => {
return typeof item === 'string' ?
Expand Down Expand Up @@ -279,7 +288,7 @@ export default function HtmlView({
try {
const { nodes, images: imgs } = getNodes(html)
setNodes(nodes)
console.log('nodes', nodes);
// console.log('nodes', nodes);
images.current = imgs
} catch (error) {
console.error('html解析失败', error)
Expand Down

0 comments on commit 06c201d

Please sign in to comment.