-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
environment:
vue3
typescript
core methods:
type ImageEditorOptions = tuiImageEditor.IOptions & { includeUI: { locale?: Record<string, string> } };
async function init() {
if (!instanceRef.value) return;
// 单独列出来,避免 ts 报错
const options: ImageEditorOptions = {
includeUI: {
loadImage: { path: '', name: 'image' }, // 默认加载的图片
// menu: ['resize', 'crop', 'rotate', 'draw', 'shape', 'icon', 'text', 'filter'], // 底部菜单按钮列表 隐藏镜像flip和遮罩mask
initMenu: 'crop', // 默认打开的菜单项
menuBarPosition: 'bottom', // 菜单所在的位置
locale: localeCN
},
cssMaxWidth: 1000, // canvas 最大宽度
cssMaxHeight: 800, // canvas 最大高度
selectionStyle: {
cornerSize: 20,
rotatingPointOffset: 70
}
};
try {
// 1. 预加载图片,确保资源可用
const img = new Image();
img.src = props.imgUrl;
await new Promise((resolve, reject) => {
img.onload = resolve;
img.onerror = reject;
});
// 2. 销毁旧实例(如果存在)
if (instance.value) {
instance.value.destroy();
instance.value = null;
}
instance.value = markRaw(new ImageEditor(instanceRef.value, options));
await instance.value.loadImageFromURL(props.imgUrl, 'image.jpg');
await instance.value.clearObjects();
} catch (error) {
console.error('图片加载失败:', error);
}
}
Summary
After loading the remote image, the bottom control button is not available
Screenshots
Version
v3.15.3
Additional context
Control buttons are available when using local images