Skip to content

Commit 5249587

Browse files
committed
fix(uni-app-x web): ssr时page-meta-head未能传送到head下的Bug
1 parent cb9c8a9 commit 5249587

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
import type { NodeTransform } from '@vue/compiler-core'
1+
import type { ElementNode, NodeTransform } from '@vue/compiler-core'
2+
import { ElementTypes } from '@vue/compiler-core'
23
import { checkElementNodeTag } from '../../utils'
34

45
export const transformPageHead: NodeTransform = (node, context) => {
56
// 发现是page-meta下的head,直接remove该节点
6-
checkElementNodeTag(node, 'head') &&
7-
checkElementNodeTag(context.parent, 'page-meta') &&
8-
context.removeNode(node)
7+
if (
8+
checkElementNodeTag(node, 'head') &&
9+
checkElementNodeTag(context.parent, 'page-meta')
10+
) {
11+
if (process.env.UNI_APP_X === 'true') {
12+
;(node as ElementNode).tag = 'page-meta-head'
13+
;(node as ElementNode).tagType = ElementTypes.COMPONENT
14+
} else {
15+
context.removeNode(node)
16+
}
17+
}
918
}

packages/uni-h5-vite/src/plugin/transforms/transformPageHead.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { checkElementNodeTag } from '@dcloudio/uni-cli-shared'
22
import type { ElementNode, NodeTransform } from '@vue/compiler-core'
3+
import { ElementTypes } from '@vue/compiler-core'
34

45
export const transformPageHead: NodeTransform = (node, context) => {
56
if (checkElementNodeTag(node, 'page-meta')) {
@@ -8,6 +9,7 @@ export const transformPageHead: NodeTransform = (node, context) => {
89
) as ElementNode
910
if (headNode) {
1011
headNode.tag = 'page-meta-head'
12+
headNode.tagType = ElementTypes.COMPONENT
1113
}
1214
return
1315
}
@@ -16,5 +18,6 @@ export const transformPageHead: NodeTransform = (node, context) => {
1618
checkElementNodeTag(context.parent, 'page-meta')
1719
) {
1820
;(node as ElementNode).tag = 'page-meta-head'
21+
;(node as ElementNode).tagType = ElementTypes.COMPONENT
1922
}
2023
}

0 commit comments

Comments
 (0)