Gökhan YILDIZ
Gökhan YILDIZ

Reputation: 141

Nuxtjs, how to add data attribute to body tag

I need to add some data attributes for body tag. How can i do that?

<body data-spy="scroll" data-target=".navbar-nav" data-offset="110">

Upvotes: 1

Views: 3972

Answers (1)

Murat
Murat

Reputation: 1205

You can achieve that by putting your attributes in the head object of your component declaration :

<script>
export default {
  head: {
     bodyAttrs: {
       'data-spy': 'scroll',
       'data-target': '.navbar-nav',
       'data-offset': '110'
     }
  }
  // ...
}
</script>

Upvotes: 10

Related Questions