Nuxt.jsNuxt.js·

Vue - TypeError: Cannot read properties of null (reading 'insertBefore')

Published at 2024-05-05 12:19:38Viewed 232 times
Professional article
Please reprint with source link

In Vue 3/Nuxt 3, one may occur the error

TypeError: Cannot read properties of null (reading 'insertBefore')

which has little information and is hard to solve. In the following, we summerize some tips that help you solve this error :

1. Change v-if to v-show , or change all v-if , v-else to v-show. Sometimes, the error appears because there are v-if or v-if, v-else pairs.

2. Change katex auto-render. The error may appear because you use katex auto-render. To solve this, you could either change katex to mathjax, or change document.body in the auto-render function to a specific area document.getElementById(Id) as follows :

<script>
    var node = document.getElementById(Id)
    document.addEventListener("DOMContentLoaded", function() {
        renderMathInElement(node, {
          // customised options
          // • auto-render specific keys, e.g.:
          delimiters: [
              {left: '$$', right: '$$', display: true},
              {left: '$', right: '$', display: false},
              {left: '\\(', right: '\\)', display: false},
              {left: '\\[', right: '\\]', display: true}
          ],
          // • rendering keys, e.g.:
          throwOnError : false
        });
    });
</script>

If katex render all corresponding symbols in document.body, it may also influence some normal part. So you need to restrict it to a specific area.

3. Change your dialog component. If you are using SSR, like Nuxt.js, the error may occur due to your dialog component in the UI library. You could either try to wrap the dialog with ClientOnly

<ClientOnly>
    <Dialog>
    </Dialog>
</ClientOnly>

or try to use another UI library.

Comments

There is no comment, let's add the first one.

弦圈热门内容

Vue初学记录

网站开发,需要前端与后端的开发。前端指用户端、浏览器端,是用户能看得到的部分。后端指服务器端,是用户看不到的部分。前端开发,需要用到CSS3和HTML5以及JavaScript。后端开发能用的编程语言则很多了,主流的有python、java等,只要我们电脑能够使用的编程语言,服务端都能使用。目前流行前后端分离,后端只需要提供好接口就行了,前端直接使用后端的接口。前端三大框架:Vue、react、AngularVue是目前中国使用比较多的框架,因为创造这个框架的是中国人——前谷歌员工Even You。React框架则是Meta公司(原Facebook公司)创造的框架,Angular是谷歌建立的框架。从最近GitHub的数据上看,Vue是目前全世界下载量最多的框架,第二大的为React,第三为Angular。前端框架建立的目的,其实是为了方便开发,提高开发效率,降低开发难度。本质上,最后到浏览器那里,都是转换为CSS3、HTML5、JavaScript的语言。前端的开发,代码实现前,还需要设计UI界面,提高用户体验。因此,网站前后端开发分别对应三个职位——前端工程师、后端工程师、UI设计师 ...

Nginx服务器反向代理

1. nginx服务器Nginx与Apache为两大主流web服务器。而我的轻量级云服务器使用了nginx。因为nginx相比与apache更轻量,性能更好,不怎么占内存,适合中小型服务器。同时Nginx善于应对高并发场景,在多用户同时点击的情况下,服务器能负荷得住。又由于nginx的负载均衡,让多个用户打开网站没那么卡。nginx官网安装教程Installing NGINX Open Source | NGINX DocumentationDebian12安装nginx:sudo apt-get update sudo apt-get install nginx最后输入sudo nginx -v验证安装。2. Nginx服务器反向代理客户端对代理是无感知的,只需将请求发送到反向代理服务器,由反向代理服务器去选择目标服务器获取数据后,再返回给客户端,此时反向代理服务器和目标服务器对外就是一个服务器,暴露的是代理服务器地址,隐藏了真实服务器IP地址

代数几何简介

1. Introduction代数几何是数学的核心领域,也是如今国际数学界的主流。代数几何与许多数学分支都存在广泛的联系,比如数论、微分几何、代数拓扑、复几何、表示论、同调代数、交换代数、偏微分方程等等,这些分支的发展同时也对代数几何起到促进作用。数学史上的许多重大的事件,比如,费马大定理、莫德尔猜想、韦伊猜想的证明都跟代数几何有关。同时,代数几何存在广泛的应用,比如密码学、弦理论、大数据、统计学习理论等等。代数几何之下有众多分支,比如复代数几何,热带几何,算术几何,远阿贝尔几何,$p$进霍奇理论(complex algebraic geometry, tropical geometry, arithmetic geometry, anabelian geometry, p-adic hodge theory),每个分支代表代数几何研究的一个大方向,而在每个大方向下,又有各种以不同的问题为导向的子方向。在这篇文章中,我们将会对代数几何,包括它的分支算术代数几何,做一个简短的介绍。2. An Introduction to Arithmetic Geometry算术几何是算术代数几何的简 ...

Get connected with us on social networks! Twitter

©2024 Guangzhou Sinephony Technology Co., Ltd All Rights Reserved