I
I
Igor Koch2017-08-01 01:53:54
JavaScript
Igor Koch, 2017-08-01 01:53:54

How to insert a background image in PUG + NUXT?

I'm using nuxt (ssr in vue), I need to insert the image inline:

div.uk-section-media(style='background-image: url(~assets/img/logo.png)') //Не работает
  img.logo(src='~assets/img/logo.png', alt='Nuxt.js Logo') //Работает

Nuxt parses links with tilde, but doesn't see them in style, how to write them correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Koch, 2017-10-30
@amux

:style="{'background-image': 'url(' + require('~/assets/img/logo.png') + ')' }"

A
Alexey Ovdienko, 2017-08-03
@doubledare

This
In a simple template engine, it would look like this, that is, bind to an attribute, and characters are concatenated in brackets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question