yve*_*lem 5 javascript vue.js vue-multiselect
在vuejs中,有没有一种方法可以为多个广告位设置相同的内容而无需复制粘贴?
所以这:
<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>
Run Code Online (Sandbox Code Playgroud)
可以这样写:
<base-layout>
<template slot="['option', 'singleLabel']">
<span :class="'flag-icon-' props.option.toLowerCase()" />{{ countriesByCode[props.option] }}
</template>
</base-layout>
Run Code Online (Sandbox Code Playgroud)
非常感谢。
你可以尝试使用v-for它。
<base-layout>
<template :slot="slotName" v-for="slotName in ['option', 'singleLabel']">
<span :class="'flag-icon-' props.option.toLowerCase()" />{{ countriesByCode[props.option] }}
</template>
</base-layout>Run Code Online (Sandbox Code Playgroud)
请参阅工作示例。