taro3-svg

0.0.5 • Public • Published

taro3项目使用方式

  • 复制组件(cax-svg目录)到自己项目的components目录下
  • 修改components/cax-svg/index.js文件中的cax引入
// import cax from './cax'
import cax from 'taro3-svg'
  • 页面的配置文件(xxx.config.js)中使用useComponents引入该组件
  usingComponents:{
    'taro-svg': '../../components/cax-svg/index'
  }
  • 引入html和renderSVG到页面中,按照以下方式使用(renderSVG方法调用场景根据自己需求使用,以下场景是在页面加载后调用)
  import { html, renderSVG } from 'taro3-svg'
  componentsDidmount () {
    // 静态svg使用
    renderSVG(html`要渲染的svg代码`,'svg',Taro.getCurrentInstance().page)
    // 动态svg使用
    const svgHtml = {
      type: 'svg',
      props: {
        width: 100,
      },
      childrens: [
        {
          type: 'path',
          ......
        }
      ]
    }
    renderSVG(svgHtml,'svg',Taro.getCurrentInstance().page)
  }
  render() {
    <taro-svg id='svg'></taro-svg>
  }

Readme

Keywords

Package Sidebar

Install

npm i taro3-svg

Weekly Downloads

5

Version

0.0.5

License

ISC

Unpacked Size

198 kB

Total Files

82

Last publish

Collaborators

  • foreverbl