Webpacker: Unable to use image in .vue file

Created on 15 Jul 2017  路  3Comments  路  Source: rails/webpacker

I read about the example on how to use image in React file here, like so:

// React component example
// app/javascripts/packs/hello_react.jsx

import React from 'react'
import helloIcon from '../hello_react/images/icon.png'
import '../hello_react/styles/hello-react'

const Hello = props => (
  <div className="hello-react">
    <img src={helloIcon} alt="hello-icon" />
    <p>Hello {props.name}!</p>
  </div>
)

but When I try to do the same thing with Vue it doesn't work, can someone tell me if I am missing something?

<template lang="html">
  <img src="/images/zapier_logo.svg" />
</template>

<script>
import zapierLogo from 'images/zapier_logo.svg'

export default {
}
</script>

<style lang="css">
</style>

I would love to add this example to the docs too.

All 3 comments

@ankitrg Feel free to close the issue if the above solution works 馃憤

@gauravtiwari The linked repository no longer exists. Could you please update the question with a code sample? I'm also having issue in using an image inside .vue file.

Was this page helpful?
0 / 5 - 0 ratings