【问题标题】:Reference vendor folder css and js in linemanjs在 linemanjs 中引用 vendor 文件夹 css 和 js
【发布时间】:2014-07-18 18:46:35
【问题描述】:

我正在使用 linemanjs 创建一个 Web 应用程序,但是当我明确引用供应商 cssjs 文件时,它不会引用该位置。让我知道我在使用 linemanjs 时做错了什么。

我在文件中尝试过的简单事情是 -

link(rel="stylesheet",href="/vendor/css/myvendor.css")

link(rel="stylesheet",href="/css/myvendor.css")

link(rel="stylesheet",href="css/myvendor.css")

-> myvendor.css 肯定位于 vendor 下的 css 文件夹中。

【问题讨论】:

    标签: javascript html css node.js linemanjs


    【解决方案1】:

    因为没有使用基本 HTML 的这个基本标记:

    <link rel="stylesheet" type="text/css" href="css/myvendor.css">
    

    如果必须是服务器或客户端,则必须包含标记的路径。

    如果文件夹vendor包含所有文件html和包含您用于站点的文件的文件夹,则我之前包含在标签中的路径是正确的。

    如果仍然不包含这个文件 css ,问题是文件不存在或声明错误的文件名或结构 css 错误(最好发布文件 css)但我认为你找到了Inspect ElementFirebug(firefox 和 [也许] Chrome 的附加组件)的问题

    更新:啊,如果您使用 Jade,请在 you 标签内添加 'type='text/css',因为您最好定义文件类型。

    link(rel='stylesheet', href='css/myvendor.css', type='text/css' )
    

    阅读documentation of JADE

    Template inheritance
    
    If you have multiple views with a similar structure, you will end up with the same set of includes in all your views. This approach can quickly become complicated and untidy, if the number of views and includes increases.
    

    使用 Jade,您可以生成包含文件 css 的标签:

    !!! 5
    html
        head
            title Learning Inheritance
            link(rel='stylesheet', href='/css/myvendor.css')
        body
    !!!
    

    或者在其他question on StavkoverFlow发布了其他解决方案

    head
      title test include
      | <style type='text/css'>
      include css/myvendor.css
      | </style>
    

    【讨论】:

    • 我正在使用Jade,这就是为什么链接元素就像link(rel="stylesheet",href="css/myvendor.css")
    • 我试过了,但添加 'type='text/css' 并不能修复错误:(
    • PushState:在 /home/trialcode/trialcode/myapp/generated 中找不到“/css/myvendor.css” - 正在提供“generated/index.html”
    • 如果我在 cofig.js 文件中声明它会添加并压缩到 app.css 但我需要单独引用它们
    猜你喜欢
    • 2017-07-27
    • 1970-01-01
    • 2018-03-02
    • 1970-01-01
    • 1970-01-01
    • 2015-05-20
    • 1970-01-01
    • 2013-02-14
    • 2014-03-16
    相关资源
    最近更新 更多