uni-app 鸿蒙元服务无法跳转到注册为组件的页面
uni-app 鸿蒙元服务无法跳转到注册为组件的页面
| 开发环境 | 版本号 | 项目创建方式 |
|---|---|---|
| Windows | 11 | HBuilderX |
产品分类:uniapp/小程序/鸿蒙元服务
PC开发环境操作系统:Windows
HBuilderX类型:Alpha
HBuilderX版本号:4.84
第三方开发者工具版本号:DevEco Studio 6.0.0 Release
基础库版本号:无
项目创建方式:HBuilderX
示例代码:
main.js
```javascript
// 全局注册
import index3 from "@/pages/index/index3.vue";
Vue.component("idx3", index3)
const app = new Vue({
...App
})
app.$mount()
pages/index/index
```html
<template>
<view class="content">
<navigator url="/pages/index/index2">toIndex2</navigator>
<navigator url="/pages/index/index3">toIndex3</navigator>
<button @click="navigateTo('/pages/index/index3')">navigateToIndex3</button>
<button @click="redirectTo('/pages/index/index3')">redirectToIndex3</button>
</view>
</template>
<script>
export default {
methods: {
navigateTo(url) {
uni.navigateTo({
url
})
},
redirectTo(url) {
uni.redirectTo({
url
})
}
}
}
</script>
更多关于uni-app 鸿蒙元服务无法跳转到注册为组件的页面的实战教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
需求场景是tabbar页面,根据后端配置,用v-if显示不同的页面。这就要把所有可以配置的普通页面都注册为组件。这样的话,这些页面都不能跳转了。目前只能是放弃这个功能
更多关于uni-app 鸿蒙元服务无法跳转到注册为组件的页面的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在鸿蒙元服务环境中,页面跳转失败通常与页面注册方式有关。根据你提供的代码,问题可能出现在以下几个方面:
-
全局组件注册不适用于页面跳转
Vue.component("idx3", index3)这种方式注册的是Vue组件,而非uni-app页面。页面跳转需要的是在pages.json中注册的页面路径。
-
缺少pages.json配置 确保在
pages.json中正确配置了页面路由:{ "pages": [ { "path": "pages/index/index", "style": { ... } }, { "path": "pages/index/index2", "style": { ... } }, { "path": "pages/index/index3", "style": { ... } } ] }

