node.js - 如何加载动态图像 tui-image-editor?
问题描述
大家好,
我正在使用 tui-image-editor npm。我想用动态图像在引导模型中打开我的编辑器。
我遇到了这个错误
CORS 策略已阻止从源“ http://localhost:3000 ”访问“ https://bucke_test.s3.amazonaws.com/5e4cf329adb6054a45a8203a/REN_3018.jpg ”中的图像:否“Access-Control-Allow-Origin” ' 请求的资源上存在标头。因此,不允许访问源“ http://localhost:3000 ”。webpack://tui.ImageEditor/./src/js/invoker.js?:214 Uncaught (in promise) 执行命令状态被锁定。
我已经在我的 s3 存储桶中设置了 cors 权限。
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
<i className="fa fa-pencil cursor-pointer" aria-hidden="true" onClick={(e)=> this.openImageEditorModel("dynamicimageurl")}></i>
openImageEditorModel = (imageURL) =>{
document.getElementById("openImageEditor").click();
imageEditor = new ImageEditor('#tui-image-editor', {
includeUI: {
loadImage: {
path: imageURL,
name: 'Blank'
},
uiSize: {
width: '900px',
height: '500px'
},
theme: blackTheme,
menu: ['draw', 'text'],
initMenu: 'draw',
me[![enter image description here][1]][1]nuBarPosition: 'right'
},
cssMaxWidth: 600,
cssMaxHeight: 400
});
imageEditor.loadImageFromURL(imageURL, 'My sample image')
}
解决方案
也许您可以尝试在 chrome 浏览器中安装此扩展程序。我已经尝试过了,它适用于 localhost 环境
允许 CORS:访问控制允许来源。https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en
推荐阅读
- ionic-framework - Ionic pro 软件包构建失败
- c++ - 使用 ATL 进行 COM 枚举时按需获取数据
- vba - Outlook VBA 不关闭字处理
- python - Python:有时打印整个数组而不是单个单词
- google-sheets - 谷歌表格 - 返回包含值的所有行的范围
- javascript - JQuery自动完成,更改搜索子字符串
- .htaccess - 使用 .htaccess 限制对文件的直接 URL 访问
- node.js - 在 Echo Show 上循环播放视频
- java - Java:awt 侦听器中的抽象方法是否称为回调方法?
- sql-server-2008 - 如何水平(连续)显示列值并在其周围显示一些文本?