Nuxt JS code example
Example 1: nuxt install
yarn create nuxt-app <project-name>
npx create-nuxt-app <project-name>
npm init nuxt-app <project-name>
Example 2: install nuxt
$ npx create-nuxt-app <project-name>
Example 3: Nuxt js
methods: {
formatDate(date) {
const options = { year: 'numeric', month: 'long', day: 'numeric' }
return new Date(date).toLocaleDateString('en', options)
}
}
Example 4: Nuxt js
<template>
<article>
<h1>{{ article.title }}</h1>
<p>{{ article.description }}</p>
<img :src="article.image" :alt="article.alt" />
<p>Article last updated: {{ formatDate(article.updatedAt) }}</p>
<nuxt-content :document="article" />
</article>
</template>
Example 5: Nuxt JS
<template>
<article>
<h1>{{ article.title }}</h1>
<p>{{ article.description }}</p>
<img :src="require(`~/assets/images/${article.img}`)" :alt="article.alt" height="100px" />
<p>Article last updated: {{ formatDate(article.updatedAt) }}</p>
<nuxt-content :document="article" />
<NuxtLink to="/" class="button--grey">Статья 1</NuxtLink>
</article>
</template>