Beginner
Beginner

Reputation: 1740

Import composition api

Supposed I have index.ts

import { defineComponent, onMounted } from '@nuxtjs/composition-api'


const Todo = defineComponent({
  setup() {

    onMounted(() => {
      test()
    })

    function test(){

      return 'test'
    }
  },
  // You need to define an empty head to activate this functionality
  head: {},
})

export default Todo

And I have Todo.vue

 <template>
    <p>
      Hello world!
    </p>
</template>

<script lang="ts">
import Todo from './index'
export default Todo
</script>

Then importing it to other file using

<template>
  <Todo/>
</template>


<script lang="ts">
import { defineComponent} from '@nuxtjs/composition-api'

import Todo from '../../components/pages/Todo/'

export default defineComponent({
  components: {Todo},
  setup(){}
})

</script>

I'm getting an error saying render function or template not defined in component: Todo

any idea where can I start to fix this?

Upvotes: 0

Views: 319

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

Reputation: 1

Try out :

<template>
  <h1 class="test">
    Hello world!
  </h1>
</template>

<script lang="ts" src="./index.ts">

</script>

Upvotes: 1

Related Questions