Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么我这样的写法说我找不到路径 #21

Open
zjydipingxian opened this issue Apr 2, 2019 · 22 comments
Open

为什么我这样的写法说我找不到路径 #21

zjydipingxian opened this issue Apr 2, 2019 · 22 comments

Comments

@zjydipingxian
Copy link

就是我假如,底部的tab是在pages文件夹, 其他详情页,或者不是主页面都放在了views, 那我是要怎么实现路由跳转? 安装了mpvue-router-patch, 我管理的路由文件是 在src/router/index.js

@zjydipingxian
Copy link
Author

image

@zjydipingxian
Copy link
Author

image

@zjydipingxian
Copy link
Author

image

@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

tab 页 this.$router.push({ path: 'path', isTab: true })
普通页面 this.$router.push('path')
目前的实现,在小程序中,路由与 src/router/index.js 这个文件是无关的

@zjydipingxian
Copy link
Author

image
image

@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

绝对路径

@zjydipingxian
Copy link
Author

image
image

@zjydipingxian
Copy link
Author

那我就搞不懂了,路由与 src/router/index.js 这个文件是无关的 , 设置页面的标题,好像也不起作用

@F-loat F-loat closed this as completed Apr 2, 2019
@F-loat F-loat reopened this Apr 2, 2019
@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

点错了,这个库只是对小程序的路由 api 做了封装,可以用类 vue-router 的形式调用,routes.js 那个文件实际是给 mpvue-entry 使用的,另外在 h5 端可以直接复用

@zjydipingxian
Copy link
Author

那我写 this.$router.push('/src/views/a/a') 还是报错

@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

this.$router.push('/views/a/a') 和你小程序中页面的路径一致

@zjydipingxian
Copy link
Author

image
我发现打包npm run dev 出来的小程序文件夹,并没有views这个文件夹。

@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

你用的是哪个模板,app.json 和打包入口需要修改的

@zjydipingxian
Copy link
Author

我用官方的模板。

@zjydipingxian
Copy link
Author

可以说下方法,怎么修改吗?

@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

@zjydipingxian
Copy link
Author

全部复制可以吗?

@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

你直接加个 viewsEntry 也行

const pagesEntry = getEntry(resolve('./src'), 'pages/**/main.js')
const viewsEntry = getEntry(resolve('./src'), 'views/**/main.js')
const entry = Object.assign({}, appEntry, pagesEntry, viewsEntry)

@zjydipingxian
Copy link
Author

image

@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

@zjydipingxian
Copy link
Author

我这个属于分包行位了?

@F-loat
Copy link
Owner

F-loat commented Apr 2, 2019

不是啊,建议你直接用我这个模板

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants