分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

[Vue warn]: Do not mount Vue to <html> or <body> - mount to normal elements instead.

发布时间:2023-09-06 01:42责任编辑:顾先生关键词:bodyelement

官方文档是这么解释的:

提供的元素只能作为挂载点。不同于 Vue 1.x,所有的挂载元素会被 Vue 生成的 DOM 替换。因此不推荐挂载root实例到 <html> 或者 <body> 上。

这是vue2.0的最新写法,我们看到的是vue项目的主入口main.js,template是将会替换el的挂载元素的模板

区别一定是:el对应的 一定是一个css选择器,如果还是html 或者body元素,浏览器将会报错:

[Vue warn]: Do not mount Vue to <html> or <body> - mount to normal elements instead.

[Vue warn]: Do not mount Vue to <html> or <body> - mount to normal elements instead.

原文地址:https://www.cnblogs.com/xiangxinhouse/p/8447488.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved