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

怎么给 URL 加参数 #197

Open
cos800 opened this issue Dec 25, 2015 · 1 comment
Open

怎么给 URL 加参数 #197

cos800 opened this issue Dec 25, 2015 · 1 comment

Comments

@cos800
Copy link

cos800 commented Dec 25, 2015

我的页面结构大概是这样

<!-- index.html -->
<div id="pageList" class="page out">
    列表页
</div>
<div id="pageShow" class="page out">
    详情页
</div>

列表页里的链接 点击事件大概是这样处理的。

showPost: function(item) {
    // 把当前要查看的帖子数据保存到 localStorage 里
    localStorage.setItem('showPost' , JSON.stringify(item));
    // 然后切换到 #pageShow
    var intoPage = document.getElementById('pageShow');
    var outPage = $('.page.in')[0];
    Mobilebone.transition(intoPage, outPage);
}

于是浏览器里的链接变成这样了:
http://127.0.0.1:8080/#&pageShow

但是这样的链接没法分享,因为没有帖子 ID,
怎样才能切换到#pageShow且浏览器里的链接变成这样:
http://127.0.0.1:8080/#&pageShow?id=123

这样的话用户分享出去,别的用户点进来,
我就可以判断 id 与 localStorage 是否一致,
不一致的话再用 id 调用 API 获取数据。

@cos800
Copy link
Author

cos800 commented Dec 25, 2015

照目前Mobilebone现有功能来讲,
我似乎必须把#pageShow独立成一个show.html文件,
并且把点击链接改成show.html?id=123,让Mobilebone去处理点击事件。。。

但我可能没法改成链接,因为如果改成链接,就变成了嵌套链接了。

<a href="这里链接到详情页">
    <a href="">点击打开用户信息页,不是详情页</a>
    ...
</a>

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

1 participant