fix: node type check
This commit is contained in:
@@ -32,7 +32,7 @@ export default function MrakdownRender({ content }) {
|
||||
console.log(evt);
|
||||
const { target } = evt;
|
||||
// 图片
|
||||
if (target.nodeType == 1) {
|
||||
if (target.nodeName == "IMG") {
|
||||
const data = { originUrl: target.dataset.origin || target.src };
|
||||
setPreviewImage(data);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,10 @@ export default function Layout({
|
||||
(evt) => {
|
||||
console.log(evt);
|
||||
const { target } = evt;
|
||||
if (target.nodeType == 1 && target.classList.contains("preview")) {
|
||||
if (
|
||||
target.nodeName == "IMG" &&
|
||||
target.classList.contains("preview")
|
||||
) {
|
||||
const originUrl = target.dataset.origin || target.src;
|
||||
const meta = JSON.parse(target.dataset.meta || "{}");
|
||||
setPreviewImage({ originUrl, ...meta });
|
||||
|
||||
Reference in New Issue
Block a user