[Vuejs]-Duplicate code in vue.js single file component

0👍

Make use of (named) slots:

<slot name="common"></slot>

Then in the template you’re "importing":

<p slot="common">some</p>

0👍

You could alternate the second v-if like so:

<template>
    <div>
        <div v-if='value'>
        *** code here ***
        include 'path_to_file.vue.part'
        </div>
        <div v-if='!value'>
        ** another code here ***
        include 'path_to_file.vue.part'
        </div>
    </div>

</template>

Leave a comment