tmagic-editor
tmagic-editor copied to clipboard
如何实现图片上传替换填写链接
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like A clear and concise description of what you want to happen.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
我也想知道
我是这样实现的,希望能给你参考。
- 开发并注册一个组件,以
m-fields-
开头
app.component(`m-fields-upload-select`, UploadSelect)
组件的具体写法参考官方写的,如@tmagic/form/src/fields/Text.vue
等。
具体上传需要自己实现
2. 修改image组件的config,加入如下配置
{
text: '上传',
name: 'src',
src: 'component',
type: 'upload-select',
}
我这边也遇到了这样的需求。 分享一下我解决方案和遇到的问题:
- 在@tmagic/form/src/ 中新增 Upload,vue 组件;
- 组件上传成功后,不能拿本地图片资源进行预览,遇到了一个bug:切换到其他地方后再切回来,会出现图片资源丢失问题;
- 最后我的做法是,上传图片后,将链接回写到url中,进行显示;