-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #712 from Tencent/docs/image-viewer
docs(image-viewer): update code sample
- Loading branch information
Showing
21 changed files
with
384 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import Toast from 'tdesign-miniprogram/toast/index'; | ||
|
||
Component({ | ||
data: { | ||
visible: false, | ||
showIndex: false, | ||
closeBtn: false, | ||
deleteBtn: false, | ||
images: [], | ||
}, | ||
methods: { | ||
clickHandle() { | ||
this.setData({ | ||
images: [ | ||
...Array.from({ length: 6 }).fill( | ||
'https://oteam-tdesign-1258344706.cos.ap-guangzhou.myqcloud.com/miniprogram/images/preview1.png', | ||
), | ||
], | ||
showIndex: true, | ||
visible: true, | ||
}); | ||
}, | ||
onChange(e) { | ||
const { | ||
detail: { index }, | ||
} = e; | ||
Toast({ | ||
context: this, | ||
selector: '#t-toast', | ||
message: `翻到第${index + 1}个`, | ||
}); | ||
}, | ||
|
||
onDelete(e) { | ||
const { | ||
detail: { index }, | ||
} = e; | ||
Toast({ | ||
context: this, | ||
selector: '#t-toast', | ||
message: `删除第${index + 1}个`, | ||
}); | ||
}, | ||
|
||
onClose(e) { | ||
const { | ||
detail: { trigger }, | ||
} = e; | ||
if (trigger === 'overlay') { | ||
Toast({ | ||
context: this, | ||
selector: '#t-toast', | ||
message: '点击overlay关闭', | ||
}); | ||
} else if (trigger === 'button') { | ||
Toast({ | ||
context: this, | ||
selector: '#t-toast', | ||
message: `点击button关闭`, | ||
}); | ||
} | ||
this.setData({ | ||
visible: false, | ||
}); | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"component": true, | ||
"usingComponents": { | ||
"t-button": "tdesign-miniprogram/button/button", | ||
"t-toast": "tdesign-miniprogram/toast/toast", | ||
"t-image-viewer": "tdesign-miniprogram/image-viewer/image-viewer" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<t-button size="large" block bind:tap="clickHandle">基础图片预览</t-button> | ||
<t-toast id="t-toast" /> | ||
<t-image-viewer | ||
deleteBtn="{{deleteBtn}}" | ||
closeBtn="{{closeBtn}}" | ||
showIndex="{{showIndex}}" | ||
visible="{{visible}}" | ||
images="{{images}}" | ||
bind:change="onChange" | ||
bind:delete="onDelete" | ||
bind:close="onClose" | ||
></t-image-viewer> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import Toast from 'tdesign-miniprogram/toast/index'; | ||
|
||
Component({ | ||
data: { | ||
visible: false, | ||
showIndex: false, | ||
closeBtn: false, | ||
deleteBtn: false, | ||
images: [], | ||
}, | ||
methods: { | ||
clickHandle() { | ||
this.setData({ | ||
images: [ | ||
...Array.from({ length: 6 }).fill( | ||
'https://oteam-tdesign-1258344706.cos.ap-guangzhou.myqcloud.com/miniprogram/images/preview4.png', | ||
), | ||
], | ||
showIndex: true, | ||
visible: true, | ||
closeBtn: true, | ||
deleteBtn: true, | ||
}); | ||
}, | ||
onChange(e) { | ||
const { | ||
detail: { index }, | ||
} = e; | ||
Toast({ | ||
context: this, | ||
selector: '#t-toast', | ||
message: `翻到第${index + 1}个`, | ||
}); | ||
}, | ||
|
||
onDelete(e) { | ||
const { | ||
detail: { index }, | ||
} = e; | ||
Toast({ | ||
context: this, | ||
selector: '#t-toast', | ||
message: `删除第${index + 1}个`, | ||
}); | ||
}, | ||
|
||
onClose(e) { | ||
const { | ||
detail: { trigger }, | ||
} = e; | ||
if (trigger === 'overlay') { | ||
Toast({ | ||
context: this, | ||
selector: '#t-toast', | ||
message: '点击overlay关闭', | ||
}); | ||
} else if (trigger === 'button') { | ||
Toast({ | ||
context: this, | ||
selector: '#t-toast', | ||
message: `点击button关闭`, | ||
}); | ||
} | ||
this.setData({ | ||
visible: false, | ||
}); | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"component": true, | ||
"usingComponents": { | ||
"t-button": "tdesign-miniprogram/button/button", | ||
"t-toast": "tdesign-miniprogram/toast/toast", | ||
"t-image-viewer": "tdesign-miniprogram/image-viewer/image-viewer" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<t-button block bind:tap="clickHandle">有删除操作</t-button> | ||
<t-toast id="t-toast" /> | ||
<t-image-viewer | ||
deleteBtn="{{deleteBtn}}" | ||
closeBtn="{{closeBtn}}" | ||
showIndex="{{showIndex}}" | ||
visible="{{visible}}" | ||
images="{{images}}" | ||
bind:change="onChange" | ||
bind:delete="onDelete" | ||
bind:close="onClose" | ||
></t-image-viewer> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,3 @@ | ||
.image-viewer { | ||
background-color: #fff; | ||
font-size: 32rpx; | ||
line-height: 48rpx; | ||
color: rgba(0, 0, 0, 0.9); | ||
padding: 48rpx 0rpx 96rpx 0rpx; | ||
height: 100vh; | ||
|
||
.slot-wrap { | ||
background-color: #fff; | ||
padding: 10px; | ||
} | ||
|
||
.title { | ||
font-weight: bold; | ||
font-size: 40rpx; | ||
line-height: 56rpx; | ||
color: rgba(0, 0, 0, 0.9); | ||
padding: 0 32rpx; | ||
} | ||
|
||
.desc { | ||
margin-top: 16rpx; | ||
font-size: 26rpx; | ||
line-height: 36rpx; | ||
color: rgba(0, 0, 0, 0.4); | ||
padding: 0 32rpx; | ||
} | ||
|
||
.sub-title { | ||
margin-top: 40rpx; | ||
font-weight: bold; | ||
padding: 0 32rpx; | ||
} | ||
|
||
.t-button { | ||
width: 686rpx; | ||
height: 96rpx; | ||
border-radius: 8rpx; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
margin-top: 32rpx; | ||
|
||
&::after { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 200%; | ||
height: 200%; | ||
transform: scale(0.5); | ||
transform-origin: 0 0; | ||
box-sizing: border-box; | ||
border: 2rpx solid #dcdcdc; | ||
} | ||
} | ||
|
||
.demo-block__oper { | ||
padding: 0 32rpx; | ||
} | ||
.t-button { | ||
margin-bottom: 32rpx; | ||
} |
Oops, something went wrong.