uni-app 最新cli项目 新建二级页面报错 v-uni-view If this is a native custom element
uni-app 最新cli项目 新建二级页面报错 v-uni-view If this is a native custom element
示例代码:
<template>
<view>
111
</view>
</template>
操作步骤:
<template>
<view>
111
</view>
</template>
预期结果:
正常编译
实际结果:
警告报错,视图不显示
bug描述:
新建二级页面内容:<view>111</view>
报错 : moreApp.vue:8 [Vue warn]: Failed to resolve component: v-uni-view
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
at <MoreApp>
改成 <div>111</div>
页面就不提示,正常用标签全部出问题了
项目信息 | 详细信息 |
---|---|
产品分类 | uniapp/H5 |
PC开发环境操作系统 | Windows |
PC开发环境操作系统版本号 | win10 |
浏览器平台 | Chrome |
浏览器版本 | Chrome123.0.6312.59(正式版本) |
项目创建方式 | CLI |
CLI版本号 | .0.0-4000720240327002 |
更多关于uni-app 最新cli项目 新建二级页面报错 v-uni-view If this is a native custom element的实战教程也可以访问 https://www.itying.com/category-93-b0.html
上传一个测试工程
更多关于uni-app 最新cli项目 新建二级页面报错 v-uni-view If this is a native custom element的实战教程也可以访问 https://www.itying.com/category-93-b0.html
已上传,pnpm i 安装后运行至浏览器,点击首页进入页面控制台即可复现
测试工程
临时解决方案:修改 moreApp.vue 的文件名,不要以App结尾,然后试试
在 uni-app 的 CLI 项目中,如果你在新建二级页面时遇到类似 v-uni-view If this is a native custom element
的错误,通常是因为 Vue.js 在处理自定义元素时出现了问题,或者是因为某些组件没有被正确注册或引入。
以下是一些可能的解决方案:
1. 检查页面路径和文件名
确保你新建的页面路径和文件名是正确的,并且在 pages.json
中正确配置了路由。例如:
{
"pages": [
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "首页"
}
},
{
"path": "pages/second/second",
"style": {
"navigationBarTitleText": "二级页面"
}
}
]
}
2. 检查自定义组件
如果你在页面中使用了自定义组件,确保这些组件已经被正确注册。例如,在 Vue 3 中:
import MyComponent from '@/components/MyComponent.vue';
export default {
components: {
MyComponent
}
}
3. 检查 Vue 版本
确保你使用的 Vue 版本与 uni-app 兼容。uni-app CLI 项目通常使用 Vue 3,但如果你使用的是 Vue 2,可能会有一些兼容性问题。
4. 检查 v-uni-view
错误
v-uni-view
是 uni-app 内部使用的组件,通常不需要手动引入或使用。如果你在代码中直接使用了 v-uni-view
,尝试移除它。
5. 清除缓存并重新编译
有时候缓存可能会导致一些问题,尝试清除缓存并重新编译项目:
rm -rf node_modules
rm -rf unpackage
npm install
npm run dev
6. 检查 uni-app 版本
确保你使用的是最新版本的 uni-app CLI。你可以通过以下命令更新 uni-app CLI:
npm install [@dcloudio](/user/dcloudio)/uni-cli -g