【问题标题】:Meteor Iron Router : Loading public resources in inner routesMeteor Iron Router:在内部路由中加载公共资源
【发布时间】:2015-05-26 17:35:46
【问题描述】:

在我的流星应用程序中 我有一个嵌套路由

  this.route('assemble', { 
    path: '/assemble',
    title: 'Assemble',
    parent: 'home',
    controller: 'MainLayoutController'
  });  

  this.route('bottypelist', { 
    path: '/assemble/bottypelist',
    title: 'BotType - List',
    parent: 'assemble',
    controller: 'MainLayoutController',
    waitOn: function(){
      return Meteor.subscribe('myBotTypes');
    }
  });    

布局控制器在顶部加载一个徽标栏。布局模板是

<template name="mainLayout">

    <div class="logobar"  style="background-color:#FFF">
        {{> logobar}}
    </div>

    <div class="top">
        {{> yield region="header"}}
    </div>

    <div class="">
        {{> yield}}
    </div>

    <div class="bottom">
        {{> yield region="footer"}}
    </div>

</template>

标志栏模板有一个标志图像。

<template name="logobar">

<div style="width:100%; min-width:100%; background-color:black; position:fixed; z-index:1029;">
    <div class="container-fluid">
        <div class="row" style="padding-right:0px; margin-right:0px">

            <div class="com-md-4">
                <a href="{{pathFor 'home'}}"> <img src="images/holmes_logo.png" width="280px" height="70px"></a>
            </div>
        </div>
    </div>
</div>

</template>

但此图像未加载到应用程序中。 徽标链接为http://localhost:3000/assemble/images/holmes_logo.png

此链接工作正常 http://localhost:3000/images/holmes_logo.png

因此,对于外部路由,图像正在加载,但对于内部路由则没有。

我正在使用这个包来制作面包屑 monbro:iron-router-breadcrumb

【问题讨论】:

    标签: meteor iron-router


    【解决方案1】:

    您需要使用绝对 URL 来引用您的图片:

    <img src="/images/holmes_logo.png">
    

    注意路径开头的斜线吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-31
      • 2016-02-09
      相关资源
      最近更新 更多