我有路线项目。例如,当我从链接http://localhost:3000/product/kartiny/18142
到链接时,http://localhost:3000/product/frame/18142
我会看到这样的加载指示器:
但是当我只更改链接上的查询时,例如从http://localhost:3000/catalog/kartiny?product=kartiny&sort_by=views_count&pages=3
到http://localhost:3000/catalog/kartiny?product=kartiny&sort_by=views_count&pages=4
我看不到它
我怎么能强制显示它?
如果您使用nuxt-link
或$router
,您将没有任何类型的加载程序。
使用fetch()
或发出外部请求时会发生这种情况asyncData()
。
如果您正在更改路径,则这不是 axios 调用,因此没有进度条。
您可以使用这种代码手动触发进度条
<script>
export default {
fetch() {
this.$nextTick(() => {
this.$nuxt.$loading.start()
// eslint-disable-next-line nuxt/no-timing-in-fetch-data
setTimeout(() => this.$nuxt.$loading.finish(), 2000)
})
},
}
</script>
不过,我不确定这除了具有可视化加载器外是否有用。
这更像是一种类似于 YouTube 的行为,如果用户按下按钮并且他的连接速度较慢,则向用户显示页面正在加载。
以下是YouTube 的行为示例。
更多细节可以在这里找到:https : //nuxtjs.org/docs/2.x/features/loading#programmatically-starting-the-loading-bar
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句