uni-app内pages页面跳转到组件页面

我想从login页面通过点击跳转到components中的页面是需要我手动在pages.json中注册才可以跳转吗?components中的页面是组件

img

望采纳!!点击该回答右侧的“采纳”按钮即可采纳!
components中的页面是组件不属于pages页面,所以我们需要手动在pages.json中注册,才能使用uni-app的页面跳转功能进行跳转。

比如说在components目录下有一个页面组件my-page

在pages.json中添加如下代码:

{
"path": "/pages/components/my-page",
"style": {
"navigationBarTitleText": "我的页面"
}
}

然后在login页面中使用uni.navigateTo方法跳转:

uni.navigateTo({
url: '/pages/components/my-page'
});

就可以从login页面跳转到components中的my-page页面。

注意:pages.json中注册的路径是相对于src目录的路径,不要忘记前面的'/pages'。