使用演示
重要提示
因跨平台需求及性能考虑,uni-app-x[app] 采用 uts 插件实现以优化性能,这两端需要配置 uts 插件运行配置后 自定义基座 使用。其余端不受此约束,可直接使用。
资源格式
| XML | 本地文件 | 网络文件 | Base64 |
|---|---|---|---|
| √ | × | × | × |
警告
如果运行插件编辑器出现 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/caverock/androidsvg/SVGImageView; 错误提示,则表示打包自定义基座时原生插件部分并未打包,需要重新自定义基座。
Props
| 属性 | 类型 | 可选值 | 默认值 | 说明 |
|---|---|---|---|---|
| src | String | - | - | XML资源 |
| width | Number | - | 24 | 宽度 |
| height | Number | - | 24 | 高度 |
| unit | String | - | px | 宽度和高度的单位 |
组件示例
vue
<template>
<view>
<ucs-svg :src="src" />
</view>
</template>
<script>
export default {
data() {
return {
// XML资源
src: '<?xml version="1.0" encoding="UTF-8"?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="24" r="3" fill="#333"/><circle cx="24" cy="24" r="3" fill="#333"/><circle cx="36" cy="24" r="3" fill="#333"/></svg>'
}
}
}
</script>
<style>
</style>