Compare commits

...

3 Commits

Author SHA1 Message Date
neverland
9b3a473061
docs(changelog): 4.0.4 (#11407) 2022-12-23 11:14:56 +08:00
chenjiahan
5bcae75f08 release: 4.0.4 2022-12-23 11:12:20 +08:00
neverland
0ee41a41a9
fix(Image): load event missing params (#11406) 2022-12-23 11:07:40 +08:00
6 changed files with 33 additions and 6 deletions

View File

@ -19,6 +19,15 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/).
## Details
### [v4.0.4](https://github.com/vant-ui/vant/compare/v4.0.3...v4.0.4)
`2022-12-23`
**Bug Fixes**
- Field: incorrect cursor position when value length exceeds maxlength or when formatter is used [#11360](https://github.com/vant-ui/vant/issues/11360)
- Image: load event missing params [#11406](https://github.com/vant-ui/vant/issues/11406)
### [v4.0.3](https://github.com/vant-ui/vant/compare/v4.0.2...v4.0.3)
`2022-12-13`

View File

@ -19,6 +19,15 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
## 更新内容
### [v4.0.4](https://github.com/vant-ui/vant/compare/v4.0.3...v4.0.4)
`2022-12-23`
**Bug Fixes**
- Field: 修复使用 formatter 时光标位置可能错误的问题 [#11360](https://github.com/vant-ui/vant/issues/11360)
- Image: 修复 load 事件未正确触发导致 ImagePreview 报错的问题 [#11406](https://github.com/vant-ui/vant/issues/11406)
### [v4.0.3](https://github.com/vant-ui/vant/compare/v4.0.2...v4.0.3)
`2022-12-13`

View File

@ -1,6 +1,6 @@
{
"name": "vant",
"version": "4.0.3",
"version": "4.0.4",
"description": "Mobile UI Components built on Vue",
"main": "lib/vant.cjs.js",
"module": "es/index.mjs",

View File

@ -96,13 +96,22 @@ export default defineComponent({
}
);
const onLoad = (event?: Event) => {
const onLoad = (event: Event) => {
if (loading.value) {
loading.value = false;
emit('load', event);
}
};
const triggerLoad = () => {
const loadEvent = new Event('load');
Object.defineProperty(loadEvent, 'target', {
value: imageRef.value,
enumerable: true,
});
onLoad(loadEvent);
};
const onError = (event?: Event) => {
error.value = true;
loading.value = false;
@ -172,7 +181,7 @@ export default defineComponent({
const onLazyLoaded = ({ el }: { el: HTMLElement }) => {
const check = () => {
if (el === imageRef.value && loading.value) {
onLoad();
triggerLoad();
}
};
if (imageRef.value) {
@ -206,7 +215,7 @@ export default defineComponent({
onMounted(() => {
nextTick(() => {
if (imageRef.value?.complete) {
onLoad();
triggerLoad();
}
});
});

View File

@ -125,7 +125,7 @@ app.use(Lazyload);
| Event | Description | Arguments |
| ----- | ------------------------------ | ------------------- |
| click | Emitted when image is clicked | _event: MouseEvent_ |
| load | Emitted when image loaded | - |
| load | Emitted when image loaded | _event: Event_ |
| error | Emitted when image load failed | - |
### Slots

View File

@ -151,7 +151,7 @@ app.use(Lazyload);
| 事件名 | 说明 | 回调参数 |
| ------ | ------------------ | ------------------- |
| click | 点击图片时触发 | _event: MouseEvent_ |
| load | 图片加载完毕时触发 | - |
| load | 图片加载完毕时触发 | _event: Event_ |
| error | 图片加载失败时触发 | - |
### Slots