hoiheart / vue-diff

VueJS diff viewer plugin
MIT License
177 stars 14 forks source link

[Vue warn]: Component is missing template or render function. #42

Open francissebin-2hats opened 1 year ago

francissebin-2hats commented 1 year ago

Thanks in advance.

I got a Vue component(suppose ComponentX.vue) and added the following code to it. It shows [Vue warn]: Component is missing template or render function. got any solution to this?

Using Vue 3 with Inertia

<template>
    <VueDiff :mode="mode" :theme="theme" :language="language" :prev="prev" :current="current"></VueDiff>
</template>

<script>
import VueDiff from 'vue-diff';
import 'vue-diff/dist/index.css';

export default {
    components: {
        VueDiff,
    },
    data() {
        return {
            mode: 'split',
            theme: 'dark',
            language: 'plaintext',
            prev: 'prev',
            current: 'current',
        }
    },
}
</script>
dnnp2011 commented 1 year ago

It uses a mixin to inject the component into your app. Follow the example in the readme. Go to your app.js or wherever you mount your Vue app and import it there, then call app.use:

import VueDiff from 'vue-diff';

const app = createApp({ /* ... */ }).use(VueDiff, { componentName: 'VueDiff' });

Then you can use it anywhere in your Vue app without needing to import it or declare it in your components: { ... } object.