masonry - Vue 3 砌体布局
问题描述
有谁知道适用于 Vue 3 和服务器端渲染的砌体布局?
我的要求是我不能预先指定列,我希望砖石布局能够解决这个问题。
在我的 Vue 2 应用程序中,我使用的是“vue-masonry”。我还必须使用“vue-client-only”作为我的应用程序,因为我的应用程序是服务器呈现的应用程序。
<!-- Only rendered during client side rendering, vue-masonry is not support in SSR -->
<client-only>
<div
class="grid"
v-masonry="containerId"
transition-duration="0.3s"
item-selector=".grid-item">
<div
v-masonry-tile class="grid-item"
v-for="(item, i) in items"
v-bind:key="i">
<img
:src="getItemImage(item)"
:data-key=i
alt="Small preview">
</div>
</div>
</client-only>
当我在我的 Vue 3 项目中有这个时,我得到了错误
slot is not a function
我尝试使用“vue-masonry-css”,但失败了
Uncaught TypeError: Cannot read property 'use' of undefined
对于以下代码
import Vue from 'vue';
import VueMasonry from 'vue-masonry-css';
Vue.use(VueMasonry);
解决方案
我也在寻找支持 SSR 和 Vue 3 的砖石布局。由于找不到适合我的用例,我创建了https://github.com/DerYeger/vue-masonry-wall。
查看https://vue-masonry-wall.yeger.eu/上的演示,看看它是否符合您的要求。
推荐阅读
- javascript - 在 useCallback() 钩子中反应 setState 没有正确设置状态变量?
- python-3.x - 合并 Pandas 数据框(即:订单和库存),然后重新调整库存
- r - 存储嵌套循环的输出
- c++ - 找到正确版本的库
- python - 如何更改轴和标签颜色?
- arduino - 尝试在 arduino uno wifi 上使用 rgb 矩阵时“未声明 SPCR”
- python-3.x - 不要在 Django 中等待数据库结果出现在异步视图中
- zsh - 仅当我输入大写字母时,zsh 自动完成才使用区分大小写的匹配
- deep-learning - 用于视频识别的 CNN + RNN 架构
- mysql - 使用nodejs + sequelize执行插入时出错