代码之家  ›  专栏  ›  技术社区  ›  sholsinger

VBScript中的字典类型不匹配

  •  0
  • sholsinger  · 技术社区  · 17 年前

    样式表定义为:

    sub stylesheets(collection)
        for each key in collection.Keys
            response.write(stylesheet(key, collection.Item(key)))
        next
    end sub
    
    ' returns a link tag for each object in the collection
    function stylesheet(asset, media_type)
        if (media_type="") then
            media_type="screen"
        end if
        return "<link href=""" & asset_url(asset) & """ type=""text/css"" media=""" _
            &  media_type & """ />"
    end function
    

    <% stylesheets(site_stylesheets) %>
    

    其中site_样式表定义为:

    ' stylesheets is a collection of the stylesheets to be included on all pages
    Set site_stylesheets = CreateObject("Scripting.Dictionary")
    site_stylesheets.Add "css/endoworks.css", "screen"
    

    我已经很久没有做任何VBScript了。我真的很感激任何帮助。

    2 回复  |  直到 17 年前
        1
  •  0
  •   Community Mohan Dere    9 年前

    调用样式表时,请尝试删除括号。看见 this

    试试这个

    <% stylesheets site_stylesheets %>
    

    <% call stylesheets(site_stylesheets) %>
    
        2
  •  0
  •   sholsinger    17 年前

    我最后只是把循环逻辑从 stylesheets header 子[例行程序]。现在很好用。

    @测试人员101:我尝试了你的建议,但没有解决问题。

    编辑:我实际上发现我有一个 辩论 标题 子例程,其中 潜艇被叫来了。所以它试图执行 nothing 带有site_样式表的参数。真不敢相信我错过了。