File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323const joy = ' data:image/jpeg;base64,...' // 图片文件base64
2424```
2525
26+ :::tip 提示
27+ 可以配置 ` transformAssetUrls ` 使 ` src ` 属性获得与原生 ` image ` 一致的体验。
28+
29+ ``` typescript
30+ // vite.config.(js|ts)
31+
32+ import uni from ' @dcloudio/vite-plugin-uni'
33+ import { defineConfig } from ' vite'
34+
35+ export default defineConfig ({
36+ plugins: [
37+ // ...
38+ uni ({
39+ vueOptions: {
40+ template: {
41+ transformAssetUrls: {
42+ tags: {
43+ ' wd-img' : [' src' ]
44+ }
45+ }
46+ }
47+ }
48+ })
49+ ]
50+ })
51+ ```
52+
53+ 修改完成后重启开发服务即可生效,查看 [ uni-app issue #4997 ] ( https://github.com/dcloudio/uni-app/issues/4997#issuecomment-2456851123 ) 了解更多。
54+ :::
55+
2656## 插槽
2757
2858使用` loading ` ` error ` 插槽设置在图片加载时、加载失败后的展示内容
Original file line number Diff line number Diff line change @@ -23,6 +23,37 @@ When using `file import`, note that WeChat Mini Program image tag paths accept b
2323const joy = ' data:image/jpeg;base64,...' // Image file base64
2424```
2525
26+ ::: tip
27+ You can configure ` transformAssetUrls ` so that the ` src ` attribute works consistently with the native ` image ` component.
28+
29+ ``` typescript
30+ // vite.config.(js|ts)
31+
32+ import uni from ' @dcloudio/vite-plugin-uni'
33+ import { defineConfig } from ' vite'
34+
35+ export default defineConfig ({
36+ plugins: [
37+ // ...
38+ uni ({
39+ vueOptions: {
40+ template: {
41+ transformAssetUrls: {
42+ tags: {
43+ ' wd-img' : [' src' ]
44+ }
45+ }
46+ }
47+ }
48+ })
49+ ]
50+ })
51+ ```
52+
53+ After updating the configuration, restart the development server to apply the changes.
54+ For more details, see [ uni-app issue #4997 ] ( https://github.com/dcloudio/uni-app/issues/4997#issuecomment-2456851123 ) .
55+ :::
56+
2657## Slots
2758
2859Use ` loading ` and ` error ` slots to set display content during image loading and after loading failure
You can’t perform that action at this time.
0 commit comments