/
githubmirror
/
taro
Обзор
Документация
Войти
/
githubmirror
/
taro
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/document.ts
45 строк
1 KB
ZakaryCode
feat(harmony): add cpp plugin
13 мар 2025, 16:58
13 мар 2025, 16:58
9a04a67
Код
Авторство
О чём код?
import { APP, BODY, HEAD, HTML } from '../constant' import { TaroDocument } from '../dom/document' import { window } from './window' function createDocument (): TaroDocument { /** * <html> <--- document.documentElement * <head></head> <--- document.head * <body> <--- document.body * <container> * <app id="app" /> * </container> * </body> * </html> */ const doc = new TaroDocument(window) const documentCreateElement = doc.createElement.bind(doc) const html = documentCreateElement(HTML) const head = documentCreateElement(HEAD) const body = documentCreateElement(BODY) const container = documentCreateElement('container') // 多包一层主要为了兼容 vue const app = documentCreateElement(APP) const entryAsync = documentCreateElement('entryAsync') app.id = 'app' entryAsync.id = 'entryAsync' doc.appendChild(html) html.appendChild(head) html.appendChild(body) body.appendChild(container) container.appendChild(app) container.appendChild(entryAsync) doc.documentElement = html doc.head = head doc.body = body doc.container = container doc.app = app doc.entryAsync = entryAsync return doc } export const document = createDocument()