以下是我现在profile-bloghistory.wxml的所有代码,van-开头的是有赞的组件。
<
view
>
<
block
wx:for
=
"{{blogList}}"
wx:key
=
"_id"
>
<
van-swipe-cell
right-width
=
"{{ 100 }}"
>
<
view
class
=
"blog-panel"
>
<
van-cell
>
<
ink-blog-card
blog
=
"{{item}}"
bind:tap
=
"goComment"
data-blogid
=
"{{item._id}}"
/>
<
ink-blog-ctrl
blogId
=
"{{item._id}}"
blog
=
"{{item}}"
iconfont
=
"iconfont"
icon-pinglun
=
"icon-pinglun"
icon-fenxiang
=
"icon-fenxiang"
/>
</
van-cell
>
</
view
>
<
view
slot
=
"right"
class
=
"delete"
>
<
view
class
=
"txt"
>删除</
view
>
</
view
>
</
van-swipe-cell
>
</
block
>
</
view
>
以下是我现在profile-bloghistory.json的所有代码,van-dialog是一个弹出对话框,我不知道需不需要加,就先加上了。
{
"usingComponents": {
"ink-blog-card": "/components/blog-card/blog-card",
"ink-blog-ctrl": "/components/blog-ctrl/blog-ctrl",
"van-cell": "/miniprogram_npm/@vant/weapp/cell/index",
"van-cell-group": "/miniprogram_npm/@vant/weapp/cell-group/index",
"van-swipe-cell": "/miniprogram_npm/@vant/weapp/swipe-cell/index",
"van-dialog": "/miniprogram_npm/@vant/weapp/dialog/index"
},
"navigationBarTitleText": "我的发布"
}
以下是贴在profile-bloghistory.js文档里的,从有赞官方搬运过来的,删除了一个case 'left',因为只需要实现右滑删除的功能,只在原课程代码的基础上添加了这部分代码,别的什么代码都没有加。
onClose(event) {
const { position, instance } = event.detail;
switch (position) {
case 'cell':
instance.close();
break;
case 'right':
Dialog.confirm({
message: '确定删除吗?'
}).then(() => {
instance.close();
});
}
},