Let's analyze the code snippet below, which utilizes a method and an imported function:
<template>
<div>
{{sayHello()}}
{{sayDate()}}
{{DateTime.now()}}
<div>
</template>
<script>
import {DateTime} from "luxon"
export default {
methods: {
sayHello() {
return "hello"
},
sayDate() {
return DateTime.now()
}
}
}
</script>
sayHello()
is functioning correctly as it is defined withinmethods
.sayDate()
is working fine too.However, using
DateTime.now()
in the<template>
section results in a failure message:[Vue warn]: Property or method "DateTime" is not defined on the instance but referenced during render.
How can we properly reference DateTime
within the <template>
for correct functionality?