typescript Ionic 3 - 一个标签 href 内部链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48793943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ionic 3 - a tag href internal link
提问by jonwa
So I'm new to Ionic and Angular and I had a question regarding internal links within the Ionic framework. So as a learning base I made the pre-made project ionic sidemenu and I'm trying to get an A tag on the home page to be linked (href) to open the list page. However, I cannot figure it out because I keep getting errors.
所以我是 Ionic 和 Angular 的新手,我有一个关于 Ionic 框架内的内部链接的问题。因此,作为学习基础,我制作了预制项目 ionic sidemenu,我试图在主页上获得一个 A 标签以链接 (href) 以打开列表页面。但是,我无法弄清楚,因为我不断收到错误。
Something like:
就像是:
<a button href="../list/list.html"></a>
But the href isn't working because I think you have to call /list/list as a package with typescript??
但是 href 不起作用,因为我认为您必须将 /list/list 作为带有打字稿的包调用?
Does anyone know the solution?
有谁知道解决方案?
回答by Sampath
You're doing it wrong. Ionic has its own navigation system.So you need to use it to navigate one page to another or like so.
你这样做是错的。Ionic 有自己的导航系统。所以你需要用它来导航一个页面到另一个页面或类似的。
this.nav.push(listpage);
Please see the official doc for more info about navigationand NavController
有关导航和NavController 的更多信息,请参阅官方文档
回答by jonwa
I figured it out! I know I'm answering my own question but just in case anyone else got stuck.
我想到了!我知道我正在回答我自己的问题,但以防万一其他人被卡住了。
https://ionicframework.com/docs/components/#navigation
https://ionicframework.com/docs/components/#navigation
Make sure that the goToOtherPage() function is NOT in the constructor but only the export class in the typescript file.
确保 goToOtherPage() 函数不在构造函数中,而只是在打字稿文件中的导出类。