# Vue

// vue2
export default {
  name: 'TempVar',
  functional: true,
  render(h, ctx) {
    return ctx.scopedSlots.default && ctx.scopedSlots.default(ctx.props || {})
  }
}
1
2
3
4
5
6
7
8
<template>
  <div>
    <TempVar
      :var1="`Hello ${name}`"
      :var2="version"
    >
      <!-- 作用域插槽 -->
      <template v-slot="{ var1, var2 }">
        <span>{{var1}}</span>
        <span>{{var2}}</span>
      </template>
    </TempVar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: 'Vue',
      version: 2
    }
  }
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

# ant-design-vue-pro

Last Updated: 3/13/2023, 10:43:35 AM