【问题标题】:HTML page does not load after clicking href, but after a reload it does单击href后HTML页面不加载,但重新加载后它会加载
【发布时间】:2017-11-29 00:16:52
【问题描述】:

我的 href 不起作用。 href 的链接在浏览器 (Chrome) 中正确显示,但没有呈现页面。在浏览器中点击刷新按钮后,页面正确呈现。

我不知道这是否重要,但我使用助手生成了 href-link,它是一个 MongoDB 数组。

这是我的数据:

{
    "_id" : "n8usBgSfG8NQRwRxD",
    "linkGenerator" : [ 
        "ABC(8f6b1d521b7bd452)", 
        "ABC(c1348b440c15ec52)"
    ],
}

这是我的助手:

Template.link.helpers({ 
  'unts': function() {
   if (Meteor.userId()) {
  var a = userManagement.find().fetch();

    return a;
  }
},

});

这是我的 HTML:

 {{#each unts}}
        <ul class="list-group">
        {{#each linkGenerator}}
            <li class="list-group-item">


<a href= "localhost:3000/link/{{this}}" target="_blank"> <span class="nav-label"></span>{{this}}</a>

            </li>
        {{/each}}
        </ul>
    {{/each}}

这是我的路线(铁路由):

Router.route('/link/:opened',{

  waitOn: function() {
  var params = this.params;
  Session.set('opened', params.opened);
  },

  action: function() {
  this.render('link');
  this.layout('blankLayout');
},

});

我只是不知道为什么它不起作用,当我点击href时,但当我刷新页面时却可以正常工作。

【问题讨论】:

    标签: javascript html meteor hyperlink routes


    【解决方案1】:

    似乎不是一个“值得”的话题……

    但是,在找到解决方案之前,我被困了好几个小时。因此,这是我如何让它工作的方式:

    我只用它的片段“/link/{{this}}”替换了href中的完整链接。因此其余的工作正常,它只是一个标签。

    【讨论】:

      【解决方案2】:

      你可以使用类似的东西

      <button
          type="button"
          onClick={(e) => {
            e.preventDefault();
            window.location.href='http://google.com';
            }}
      >CLICK ME</button>
      

      【讨论】:

        猜你喜欢
        • 2018-05-26
        • 1970-01-01
        • 2021-09-10
        • 1970-01-01
        • 2015-02-26
        • 2018-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多