0
HTMLタグ(要素)をVue 2のデータまたはプロパティの値にバインドすることは可能ですか?HTMLタグをデータまたは小道具にバインドする
私はさまざまな構文を試しましたが、動作することができず、グーグルが助けになりませんでした。
直接 'string' に補間::
<{{ someProp ? 'button' : 'a' }}>
<!-- Some complex template I want to keep DRY -->
</{{ someProp ? 'button' : 'a' }}>
V-バインドテンプレート要素にタグを(希望に満ち推測):
<template :tag="someProp ? 'button' : 'a'">
<!-- Some complex template I want to keep DRY -->
</template >
は、ここで私が試したの構文の2つです
これが不可能な場合、関連するHTMLタグを変更するために要素のコンテンツと属性を複製することを避けるにはどうすればよいですか?私は避けたいことです:
<button v-if="someProp" /* Some attribute bindings */>
<!-- Some complex template I want to keep DRY -->
</button>
<a v-else /* Repeating the above attribute bindings */>
<!-- Repeating the above template, breaking the DRY principle -->
</a>
まさに私が必要なもの、ありがとう! :) – Lazlo