* @description 创建文字节点 * @param text * @returns
(text, options)
| 1894 | * @returns |
| 1895 | */ |
| 1896 | function createTextNode(text, options) { |
| 1897 | const { onCreated, beforeCreat, onMounted, beforeMount } = options || {}; |
| 1898 | // 创建元素前 |
| 1899 | beforeCreat && beforeCreat(); |
| 1900 | // Ref |
| 1901 | if (isRef(text)) { |
| 1902 | // ref |
| 1903 | const refVal = text; |
| 1904 | // 元素 |
| 1905 | const ele = document.createTextNode(''); |
| 1906 | // 订阅变化 |
| 1907 | watchEffect(() => { |
| 1908 | ele.data = refVal.value; |
| 1909 | }); |
| 1910 | // 创建元素后 |
| 1911 | onCreated && onCreated(); |
| 1912 | return { ele, beforeMount, onMounted }; |
| 1913 | } |
| 1914 | // 创建元素后 |
| 1915 | onCreated && onCreated(); |
| 1916 | return { ele: document.createTextNode(String(text)), beforeMount, onMounted }; |
| 1917 | } |
| 1918 | /** |
| 1919 | * @description 挂载元素 |
| 1920 | * @param eleOptions |
no test coverage detected