利用SVG标签制作一个电子发票的签章

废话不多说,代码如下: 

<template>
  <div>
    <div class="mod-e-invoice">
      <div class="invoice-content">
        <!-- 电子发票章 -->
        <div class="invoice">
          <svg viewBox="0,0,900,600" height="350">
            <!-- 外环 -->
            <path d="M15 300 a435 284 0 1 1 0 1 z" fill="none" stroke="red" stroke-width="30"></path>
            <path d="M40 300 a410 260 0 1 1 0 1 z" fill="none" stroke="red" stroke-width="3"></path>

            <!-- 上半文字 -->
            <path d="M140 300 A310 160 0 0 1 760 300 " fill="none" stroke-width="1" id="circle-top"></path>
            <text class="invoice-tip">
              <textPath xlink:href="#circle-top" startOffset="50%">全国统一发票监制章</textPath>
            </text>

            <!-- 中间文字 -->
            <path d="M0 350 L900 350" id="mid-line"></path>
            <text class="invoice-tip">
              <textPath xlink:href="#mid-line" startOffset="50%">国家税务总局</textPath>
            </text>

            <!-- 下半弧文字 -->
            <path d="M80 300 A370 220 1 0 0 820 300 " fill="none" stroke-width="1" id="circle-bottom"></path>
            <text class="invoice-tip">
              <textPath xlink:href="#circle-bottom" startOffset="50%">山西省税务局</textPath>
            </text>
          </svg>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import invoiceTest from './ts/invoice-test';
export default invoiceTest;
</script>
<style lang="scss" scoped>
.mod-e-invoice {
  height: 600px;
  
  .invoice-content{
    height: 100%;
    position: relative;
    .invoice {
    transform: scale(0.3);
    width: 525px;
    margin: 0 auto;
    position: relative;
    top: -110px;
    .invoice-tip {
      text-anchor: middle;
      font-size: 20mm;
      fill: red;
      font-family: KaiTi;
    }
  }
  }

}
</style>

实现效果:

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用SVG制作一个横向树形结构,可以按以下步骤进行: 1. 首先,使用Vue创建一个组件,命名为Tree。 2. 在Tree组件中,使用SVG标签来绘制树形结构。SVG是一种可缩放矢量图形格式,可以通过代码来描述图形,非常适合用来绘制图形化的数据结构。 3. 在SVG标签中,使用<g>标签来组合多个图形元素,形成一个组合。 4. 使用<path>标签来绘制树形结构中的线条。可以使用<path>标签的d属性来定义绘制路径,例如M x1 y1 L x2 y2表示从点(x1,y1)到点(x2,y2)绘制一条直线。 5. 使用<circle>标签来绘制树形结构中的节点。可以使用<circle>标签的cx和cy属性来定义圆心坐标,r属性来定义半径。 6. 在Tree组件中,使用props属性来接收传入的树形结构数据。可以使用递归的方式,将树形结构数据中的每个节点都绘制出来。 下面是一个简单的示例代码: ```html <template> <svg> <g> <path :d="line.path" stroke="black" fill="none" /> <circle :cx="node.x" :cy="node.y" :r="node.r" fill="red" /> <text :x="node.x" :y="node.y">{{ node.value }}</text> </g> <tree v-for="child in node.children" :node="child" :key="child.id" /> </svg> </template> <script> export default { name: "Tree", props: { node: { type: Object, required: true, }, }, computed: { line() { const { x, y, width, height } = this.node; const path = `M ${x} ${y + height / 2} H ${x + width}`; return { path }; }, }, components: { Tree, }, }; </script> ``` 在这个示例中,我们定义了一个Tree组件,接收一个node属性作为参数。每个Tree组件都会绘制一个节点和一条线条,然后递归地绘制子节点。在计算属性line中,我们使用节点的位置和尺寸信息来计算线条的路径。在模板中,我们使用<g>标签来组合多个图形元素,使用v-for指令来遍历子节点,并递归地渲染Tree组件。 当我们使用这个Tree组件时,可以将树形结构数据作为参数传入: ```html <template> <tree :node="treeData" /> </template> <script> import Tree from "./Tree.vue"; export default { name: "App", components: { Tree, }, data() { return { treeData: { id: 1, value: "root", children: [ { id: 2, value: "child 1", children: [ { id: 4, value: "grandchild 1", children: [], }, { id: 5, value: "grandchild 2", children: [], }, ], }, { id: 3, value: "child 2", children: [], }, ], }, }; }, }; </script> ``` 这样就可以在Vue中使用SVG绘制出一个横向树形结构了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值