多个模板广告位的广告位内容相同 [英] Same slot content for multiple template slots

查看:90
本文介绍了多个模板广告位的广告位内容相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vuejs中,有没有一种方法可以在不复制粘贴的情况下为多个广告位设置相同的内容?

In vuejs, is there a way to set the same content for multiple slots without copy pasting?

所以这个:

<base-layout>
  <template slot="option">
    <span :class="'flag-icon-'   props.option.toLowerCase()" />{{ countriesByCode[props.option] }}
  </template>

  <template slot="singleLabel">
    <span :class="'flag-icon-'   props.option.toLowerCase()" />{{ countriesByCode[props.option] }}
  </template>
</base-layout>

可以这样写:

<base-layout>
  <template slot="['option', 'singleLabel']">
    <span :class="'flag-icon-'   props.option.toLowerCase()" />{{ countriesByCode[props.option] }}
  </template>
</base-layout>

非常感谢.

推荐答案

您可以尝试使用 v-for .

You could try using v-for for that.

<base-layout>
  <template :slot="slotName" v-for="slotName in ['option', 'singleLabel']">
    <span :class="'flag-icon-'   props.option.toLowerCase()" />{{ countriesByCode[props.option] }}
  </template>
</base-layout>

请参见工作示例.

这篇关于多个模板广告位的广告位内容相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆