我开始以自主模式测试Nancy。到目前为止,除了一个令我烦恼的问题之外,还有这么好:我如何防止它在开发过程中缓存我的观点?
我确实注意到comment视图缓存应该在调试模式下被禁用但它似乎对我不起作用 - 每当我对HTML进行更改时我都必须重新启动应用程序。
我正在使用Nancy 0.10内置超级简单视图引擎和.html文件。
答案 0 :(得分:5)
默认情况下,在调试模式下禁用缓存 。我唯一能想到的是,在自托管(即非Web项目)中运行时,调试模式检测可能存在错误。
请你试试以下
如果DisableCaches为true,则忽略使用DefaultViewCache类型https://github.com/NancyFx/Nancy/blob/master/src/Nancy/ViewEngines/DefaultViewCache.cs#L30
中的缓存答案 1 :(得分:0)
TheCodeJunkies answer适用于Nancy 1.x版。
对于Nancy 2.x,<Route path={`/topics/:id`} render={() => <Topic persons={props.persons} />} />
和 const Topic = (props) =>{
console.log('props are ', props) //logs array of persons
return(
<div>
<h2>Topic</h2>
<p>I have been rendered</p>
</div>
)
}
const Topic = ({match}) =>{
console.log('match is ', match) //logs match parameter, but now i can't access persons
return(
<div>
<h2>Topic</h2>
<p>I have been rendered</p>
</div>
)
}
属性处理是否缓存视图。可以在您的runtimeViewDiscovery
类中对此进行更改,如下所示:
runtimeViewUpdates